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 @@ -26,6 +26,7 @@
- [pull #737] Fix XSS from code spans that the span gamut doesn't treat as code spans in safe mode (#726)
- [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`


## 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 @@ -3685,7 +3685,7 @@ class FencedCodeBlocks(Extra):

fenced_code_block_re = re.compile(r'''
(?:\n+|\A\n?|(?<=\n))
(^[ \t]*`{3,})\s{0,99}?([\w+-]+)?\s{0,99}?\n # $1 = opening fence (captured for back-referencing), $2 = optional lang
(^[ \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
''', re.M | re.X | re.S)
Expand Down
18 changes: 18 additions & 0 deletions test/tm-cases/fenced_code_blocks_lang_with_symbols.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="codehilite">
<pre><span></span><code><span class="cp">#region Setup</span>
<span class="kt">var</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span>
<span class="cp">#endregion</span>
</code></pre>
</div>

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

<div class="codehilite">
<pre><span></span><code><span class="k">let</span><span class="w"> </span><span class="nv">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span>
</code></pre>
</div>

<div class="codehilite">
<pre><span></span><code><span class="k">Dim</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="ow">As</span><span class="w"> </span><span class="kt">Integer</span>
</code></pre>
</div>
1 change: 1 addition & 0 deletions test/tm-cases/fenced_code_blocks_lang_with_symbols.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_lang_with_symbols.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extra fenced-code-blocks pygments pygments>=2.21
15 changes: 15 additions & 0 deletions test/tm-cases/fenced_code_blocks_lang_with_symbols.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```c#
#region Setup
var x = 1;
#endregion
```

Some *text* between the blocks.

```f#
let x = 1
```

```vb.net
Dim x As Integer
```
Loading