Skip to content

Commit e7d753f

Browse files
Merge pull request #582 from Crozzers/fcb-and-lists
Fix fenced code blocks breaking lists (#580)
2 parents 5aae144 + d7b6863 commit e7d753f

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [pull #576] Fix `html`, `head` and `body` tags being wrapped in `<p>` tags (#575)
1313
- [pull #581] Add type hints (#562)
1414
- [pull #581] Drop Python 3.6 and 3.7 support
15+
- [pull #582] Fix fenced code blocks breaking lists (#580)
1516

1617

1718
## python-markdown2 2.4.13

lib/markdown2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,7 @@ def sub(self, match: re.Match) -> str:
28722872

28732873
tags = self.tags(lexer_name)
28742874

2875-
return "\n%s%s%s\n%s\n" % (leading_indent, tags[0], codeblock, tags[1])
2875+
return "\n%s%s%s\n%s%s\n" % (leading_indent, tags[0], codeblock, leading_indent, tags[1])
28762876

28772877
def run(self, text):
28782878
return self.fenced_code_block_re.sub(self.sub, text)

test/tm-cases/fenced_code_blocks_simple.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@
1212

1313
<pre><code> is indentation maintained?
1414
</code></pre>
15+
16+
<p>Here's one in a list, with another one following (see #580):</p>
17+
18+
<ul>
19+
<li>List 1
20+
<pre><code>code 1
21+
22+
code 2
23+
</code></pre></li>
24+
</ul>
25+
26+
<pre><code>code 3
27+
</code></pre>

test/tm-cases/fenced_code_blocks_simple.text

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,16 @@ Here is one at the end of the file:
1414
```
1515
is indentation maintained?
1616
```
17+
18+
Here's one in a list, with another one following (see #580):
19+
20+
* List 1
21+
```
22+
code 1
23+
24+
code 2
25+
```
26+
27+
```
28+
code 3
29+
```

0 commit comments

Comments
 (0)