Skip to content

Commit

Permalink
Merge pull request #1762 from sebix/fix-1761
Browse files Browse the repository at this point in the history
markdown: stricter detection of embedded markup
  • Loading branch information
RogerHaase authored Sep 14, 2024
2 parents 8fe0d22 + f1de249 commit 07ee456
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/moin/converters/_tests/test_markdown_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ def test_wikilinks(self, input, output):
def test_admonition(self, input, output):
self.do(input, output)

data = [
("one < two", "<p>one &lt; two</p>"),
("[[one]] < two", '<p><a xlink:href="wiki.local:one">one</a> &lt; two</p>'),
("pre <strong>bold</strong> post", "<div><p>pre <strong>bold</strong> post</p></div>"),
]

@pytest.mark.parametrize("input,output", data)
def test_embedded_markup(self, input, output):
"""Test embedded markup in markdown"""
self.do(input, output)

def serialize_strip(self, elem, **options):
result = serialize(elem, namespaces=self.namespaces, **options)
return self.output_re.sub("", result)
Expand Down
3 changes: 2 additions & 1 deletion src/moin/converters/markdown_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ def convert_embedded_markup(self, node):
"""
for idx, child in enumerate(node):
if isinstance(child, str):
if "<" in child:
# search for HTML tags
if re.search("<[^ ].*?>", child):
node[idx] = self.embedded_markup(child) # child is immutable string, so must do node[idx]
else:
# do not convert markup within a <pre> tag
Expand Down

0 comments on commit 07ee456

Please sign in to comment.