aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/extensions
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2015-02-05 22:23:52 -0500
committerWaylan Limberg <waylan.limberg@icloud.com>2015-02-05 22:23:52 -0500
commit9f6b45f8944a2d91041e941da609e5ac09373e22 (patch)
treeb61016122f7b8d35257b4619f5cb259c202c2498 /markdown/extensions
parent75855cdcca179f2a332bddfc4ea7c9730f701360 (diff)
downloadmarkdown-9f6b45f8944a2d91041e941da609e5ac09373e22.tar.gz
markdown-9f6b45f8944a2d91041e941da609e5ac09373e22.tar.bz2
markdown-9f6b45f8944a2d91041e941da609e5ac09373e22.zip
Added a 'use_pygments' config option to CodeHilite.
Fixes #386. I'm doing this against my better judgement. The only reason is that I'm using the HTML format suggested by the HTML5 Spec and will simply not consider any alternate output. If a JavaScript library requires something else, to bad. I don't care. That library should support the format suggested by the spec or I'm not interested in it. If you want something else then you can create your own extension which does whatever you want.
Diffstat (limited to 'markdown/extensions')
-rw-r--r--markdown/extensions/codehilite.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py
index f1e51f9..0657c37 100644
--- a/markdown/extensions/codehilite.py
+++ b/markdown/extensions/codehilite.py
@@ -75,7 +75,7 @@ class CodeHilite(object):
def __init__(self, src=None, linenums=None, guess_lang=True,
css_class="codehilite", lang=None, style='default',
- noclasses=False, tab_length=4, hl_lines=None):
+ noclasses=False, tab_length=4, hl_lines=None, use_pygments=True):
self.src = src
self.lang = lang
self.linenums = linenums
@@ -85,6 +85,7 @@ class CodeHilite(object):
self.noclasses = noclasses
self.tab_length = tab_length
self.hl_lines = hl_lines or []
+ self.use_pygments = use_pygments
def hilite(self):
"""
@@ -102,7 +103,7 @@ class CodeHilite(object):
if self.lang is None:
self._parseHeader()
- if pygments:
+ if pygments and self.use_pygments:
try:
lexer = get_lexer_by_name(self.lang)
except ValueError:
@@ -211,7 +212,8 @@ class HiliteTreeprocessor(Treeprocessor):
css_class=self.config['css_class'],
style=self.config['pygments_style'],
noclasses=self.config['noclasses'],
- tab_length=self.markdown.tab_length
+ tab_length=self.markdown.tab_length,
+ use_pygments=self.config['use_pygments']
)
placeholder = self.markdown.htmlStash.store(code.hilite(),
safe=True)
@@ -231,9 +233,6 @@ class CodeHiliteExtension(Extension):
self.config = {
'linenums': [None,
"Use lines numbers. True=yes, False=no, None=auto"],
- 'force_linenos': [False,
- "Depreciated! Use 'linenums' instead. Force "
- "line numbers - Default: False"],
'guess_lang': [True,
"Automatic language detection - Default: True"],
'css_class': ["codehilite",
@@ -244,7 +243,11 @@ class CodeHiliteExtension(Extension):
'(Colorscheme) - Default: default'],
'noclasses': [False,
'Use inline styles instead of CSS classes - '
- 'Default false']
+ 'Default false'],
+ 'use_pygments': [True,
+ 'Use Pygments to Highlight code blocks. '
+ 'Disable if using a JavaScript library. '
+ 'Default: True']
}
super(CodeHiliteExtension, self).__init__(*args, **kwargs)