MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / CodeHiliteExtension

Class CodeHiliteExtension

markdown/extensions/codehilite.py:200–219  ·  view source on GitHub ↗

Add source code hilighting to markdown codeblocks.

Source from the content-addressed store, hash-verified

198
199
200class CodeHiliteExtension(markdown.Extension):
201 """ Add source code hilighting to markdown codeblocks. """
202
203 def __init__(self, configs):
204 # define default configs
205 self.config = {
206 'force_linenos' : [False, "Force line numbers - Default: False"],
207 'css_class' : ["codehilite",
208 "Set class name for wrapper <div> - Default: codehilite"],
209 }
210
211 # Override defaults with user settings
212 for key, value in configs:
213 self.setConfig(key, value)
214
215 def extendMarkdown(self, md, md_globals):
216 """ Add HilitePostprocessor to Markdown instance. """
217 hiliter = HiliteTreeprocessor(md)
218 hiliter.config = self.config
219 md.treeprocessors.add("hilite", hiliter, "_begin")
220
221
222def makeExtension(configs={}):

Callers 1

makeExtensionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected