Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [pull #743] Add a `strip-syntax` option to the `header-ids` extra that leaves link URLs, image paths, inline HTML tags and emphasis markers out of header ids (#192)
- [pull #747] Fix `link-patterns` extra linking text inside Markdown links and images whose label wraps onto another line
- [pull #759] Fix `fenced-code-blocks` extra not recognizing code blocks whose language name contains `#` or `.`, such as `c#`, `f#` and `vb.net`
- [pull #760] Fix `fenced-code-blocks` extra ending a code block early at a line inside it that ends with backticks, such as an indented fence in a docstring


## python-markdown2 2.5.5
Expand Down
2 changes: 1 addition & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3690,7 +3690,7 @@ class FencedCodeBlocks(Extra):
(?:\n+|\A\n?|(?<=\n))
(^[ \t]*`{3,})\s{0,99}?([\w+\#.-]+)?\s{0,99}?\n # $1 = opening fence (captured for back-referencing), $2 = optional lang
(.*?) # $3 = code block content
\1[ \t]*\n # closing fence
^[ ]{0,3}\1`*[ \t]*\n # closing fence
''', re.M | re.X | re.S)

def test(self, text: str):
Expand Down
19 changes: 19 additions & 0 deletions test/tm-cases/fenced_code_blocks_closing_fence.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<pre><code>def greet():
"""Say hello.

```
greet()
```
"""
</code></pre>

<p>Some <em>text</em> between the blocks.</p>

<pre><code>Wrap code in ```
</code></pre>

<pre><code>closing fence indented by three spaces
</code></pre>

<pre><code>closing fence longer than the opening one
</code></pre>
1 change: 1 addition & 0 deletions test/tm-cases/fenced_code_blocks_closing_fence.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"extras": ["fenced-code-blocks"]}
1 change: 1 addition & 0 deletions test/tm-cases/fenced_code_blocks_closing_fence.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extra fenced-code-blocks
23 changes: 23 additions & 0 deletions test/tm-cases/fenced_code_blocks_closing_fence.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```
def greet():
"""Say hello.

```
greet()
```
"""
```

Some *text* between the blocks.

```
Wrap code in ```
```

```
closing fence indented by three spaces
```

```
closing fence longer than the opening one
````
Loading