Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ ENV/

# MkDocs documentation
site/

# Mac files
.DS_Store
1 change: 1 addition & 0 deletions docs/change_log/release-3.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ The following bug fixes are included in the 3.3 release:
* Fix complex scenarios involving lists and admonitions (#1004).
* Fix complex scenarios with nested ordered and unordered lists in a definition list (#918).
* Fix corner cases with lists under admonitions.
* Don't process shebangs in fenced code blocks when using CodeHilite (#1156).

[spec]: https://www.w3.org/TR/html5/text-level-semantics.html#the-code-element
[fenced_code]: ../extensions/fenced_code_blocks.md
Expand Down
4 changes: 2 additions & 2 deletions markdown/extensions/codehilite.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(self, src, **options):

self.options = options

def hilite(self):
def hilite(self, shebang=True):
"""
Pass code to the [Pygments](http://pygments.pocoo.org/) highliter with
optional line numbers. The output should then be styled with css to
Expand All @@ -125,7 +125,7 @@ def hilite(self):

self.src = self.src.strip('\n')

if self.lang is None:
if self.lang is None and shebang:
self._parseHeader()

if pygments and self.use_pygments:
Expand Down
2 changes: 1 addition & 1 deletion markdown/extensions/fenced_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def run(self, lines):
**local_config
)

code = highliter.hilite()
code = highliter.hilite(shebang=False)
else:
id_attr = lang_attr = class_attr = kv_pairs = ''
if lang:
Expand Down
30 changes: 30 additions & 0 deletions tests/test_syntax/extensions/test_fenced_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,36 @@ def setUp(self):
if has_pygments and pygments.__version__ != required_pygments_version:
self.skipTest(f'Pygments=={required_pygments_version} is required')

def test_shebang(self):

if has_pygments:
expected = '''
<div class="codehilite"><pre><span></span><code>#!test
</code></pre></div>
'''
else:
expected = '''
<pre class="codehilite"><code>#!test
</code></pre>
'''

self.assertMarkdownRenders(
self.dedent(
'''
```
#!test
```
'''
),
self.dedent(
expected
),
extensions=[
markdown.extensions.codehilite.CodeHiliteExtension(linenums=None, guess_lang=False),
'fenced_code'
]
)

def testFencedCodeWithHighlightLines(self):
if has_pygments:
expected = self.dedent(
Expand Down