Skip to content

Commit

Permalink
Preserve text immediately before an admonition
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin authored Dec 30, 2020
1 parent 4b83620 commit 12be7c9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/change_log/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Under development: version 3.3.4 (a bug-fix release).
* Properly parse unclosed tags in code spans (#1066).
* Properly parse processing instructions in md_in_html (#1070).
* Properly parse code spans in md_in_html (#1069).
* Preserve text immediately before an admonition (#1092).
* Simplified regex for HTML placeholders (#928) addressing (#932).

Oct 25, 2020: version 3.3.3 (a bug-fix release).
Expand Down
2 changes: 2 additions & 0 deletions markdown/extensions/admonition.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def run(self, parent, blocks):
m = self.RE.search(block)

if m:
if m.start() > 0:
self.parser.parseBlocks(parent, [block[:m.start()]])
block = block[m.end():] # removes the first line
else:
sibling, block = self.get_sibling(parent, block)
Expand Down
21 changes: 21 additions & 0 deletions tests/test_syntax/extensions/test_admonition.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,24 @@ def test_definition_list(self):
),
extensions=['admonition', 'def_list']
)

def test_with_preceding_text(self):
self.assertMarkdownRenders(
self.dedent(
'''
foo
**foo**
!!! note "Admonition"
'''
),
self.dedent(
'''
<p>foo
<strong>foo</strong></p>
<div class="admonition note">
<p class="admonition-title">Admonition</p>
</div>
'''
),
extensions=['admonition']
)

0 comments on commit 12be7c9

Please sign in to comment.