Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
881 additions
and
911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import re | ||
|
||
import markdown | ||
from markdown.extensions.fenced_code import FencedBlockPreprocessor | ||
|
||
|
||
class CodeBlockExtension(markdown.Extension): | ||
def extendMarkdown(self, md): | ||
md.registerExtension(self) | ||
|
||
md.preprocessors.add( | ||
"misago_code_bbcode", CodeBlockPreprocessor(md), ">normalize_whitespace" | ||
) | ||
|
||
|
||
class CodeBlockPreprocessor(FencedBlockPreprocessor): | ||
FENCED_BLOCK_RE = re.compile( | ||
r""" | ||
\[code(=("?)(?P<lang>.*?)("?))?](([ ]*\n)+)?(?P<code>.*?)((\s|\n)+)?\[/code\] | ||
""", | ||
re.IGNORECASE | re.MULTILINE | re.DOTALL | re.VERBOSE, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import re | ||
|
||
from markdown.blockprocessors import HRProcessor | ||
|
||
|
||
class BBCodeHRProcessor(HRProcessor): | ||
RE = r"^\[hr\]*" | ||
|
||
# Detect hr on any line of a block. | ||
SEARCH_RE = re.compile(RE, re.MULTILINE | re.IGNORECASE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
) | ||
|
||
|
||
def finalise_markup(post): | ||
def finalize_markup(post): | ||
return HEADER_RE.sub(replace_headers, post) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def request_mock(user): | ||
return Mock(scheme="http", get_host=Mock(return_value="example.com"), user=user) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# snapshottest: v1 - https://goo.gl/zC4yUc | ||
from __future__ import unicode_literals | ||
|
||
from snapshottest import Snapshot | ||
|
||
|
||
snapshots = Snapshot() | ||
|
||
snapshots["test_single_line_code 1"] = '<pre><code>echo("Hello!");</code></pre>' | ||
|
||
snapshots[ | ||
"test_multi_line_code 1" | ||
] = """<pre><code>echo("Hello!"); | ||
echo("World!");</code></pre>""" | ||
|
||
snapshots[ | ||
"test_code_with_language_parameter 1" | ||
] = '<pre><code class="php">echo("Hello!");</code></pre>' | ||
|
||
snapshots[ | ||
"test_code_with_quoted_language_parameter 1" | ||
] = '<pre><code class="php">echo("Hello!");</code></pre>' | ||
|
||
snapshots[ | ||
"test_code_block_disables_parsing 1" | ||
] = "<pre><code>Dolor [b]met.[/b]</code></pre>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
# snapshottest: v1 - https://goo.gl/zC4yUc | ||
from __future__ import unicode_literals | ||
|
||
from snapshottest import Snapshot | ||
|
||
|
||
snapshots = Snapshot() | ||
|
||
snapshots[ | ||
"test_finalization_sets_translation_strings_in_quotes 1" | ||
] = '<div class="quote-heading">Quoted message:</div>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
# snapshottest: v1 - https://goo.gl/zC4yUc | ||
from __future__ import unicode_literals | ||
|
||
from snapshottest import Snapshot | ||
|
||
|
||
snapshots = Snapshot() | ||
|
||
snapshots[ | ||
"test_hr_bbcode_is_replaced_if_its_alone_in_paragraph 1" | ||
] = """<p>Lorem ipsum dolor met.</p> | ||
<hr/> | ||
<p>Sit amet elit.</p>""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
# snapshottest: v1 - https://goo.gl/zC4yUc | ||
from __future__ import unicode_literals | ||
|
||
from snapshottest import Snapshot | ||
|
||
|
||
snapshots = Snapshot() | ||
|
||
snapshots["test_bold_bbcode 1"] = "<p>Lorem <b>ipsum</b>!</p>" | ||
|
||
snapshots["test_italics_bbcode 1"] = "<p>Lorem <i>ipsum</i>!</p>" | ||
|
||
snapshots["test_underline_bbcode 1"] = "<p>Lorem <u>ipsum</u>!</p>" | ||
|
||
snapshots[ | ||
"test_inline_bbcode_can_be_mixed_with_markdown 1" | ||
] = "<p>Lorem <b><strong>ipsum</strong></b>!</p>" | ||
|
||
snapshots[ | ||
"test_image_bbcode 1" | ||
] = '<p>Lorem <img alt="placekitten.com/g/1200/500" src="https://placekitten.com/g/1200/500"/> ipsum</p>' | ||
|
||
snapshots[ | ||
"test_image_bbcode_is_case_insensitive 1" | ||
] = '<p>Lorem <img alt="placekitten.com/g/1200/500" src="https://placekitten.com/g/1200/500"/> ipsum</p>' | ||
|
||
snapshots[ | ||
"test_url_bbcode 1" | ||
] = '<p>Lorem <a href="https://placekitten.com/g/1200/500" rel="nofollow noopener">placekitten.com/g/1200/500</a> ipsum</p>' | ||
|
||
snapshots[ | ||
"test_url_bbcode_with_link_text 1" | ||
] = '<p>Lorem <a href="https://placekitten.com/g/1200/500" rel="nofollow noopener">dolor</a> ipsum</p>' | ||
|
||
snapshots[ | ||
"test_url_bbcode_with_long_link_text 1" | ||
] = '<p>Lorem <a href="https://placekitten.com/g/1200/500" rel="nofollow noopener">dolor met</a> ipsum</p>' | ||
|
||
snapshots[ | ||
"test_url_bbcode_with_quotes_and_link_text 1" | ||
] = '<p>Lorem <a href="https://placekitten.com/g/1200/500" rel="nofollow noopener">dolor</a> ipsum</p>' | ||
|
||
snapshots[ | ||
"test_url_bbcode_with_quotes_and_long_link_text 1" | ||
] = '<p>Lorem <a href="https://placekitten.com/g/1200/500" rel="nofollow noopener">dolor met</a> ipsum</p>' |
Oops, something went wrong.