added support for fenced code blacks with highlighting

This commit is contained in:
Amy G. Bowersox 2024-08-03 00:21:26 -06:00
parent 5066ff2437
commit 4b8db948ed
4 changed files with 19 additions and 2 deletions

View File

@ -10,6 +10,7 @@ dependencies = [
"markdown~=3.6",
"markupsafe~=2.1.5",
"pyyaml~=6.0.1",
"pygments~=2.18.0",
]
readme = "README.md"
requires-python = ">= 3.8"

View File

@ -19,6 +19,8 @@ markupsafe==2.1.5
# via jinja2
nodeenv==1.9.1
# via pyright
pygments==2.18.0
# via dragonglass
pyright==1.1.373
pyyaml==6.0.1
# via dragonglass

View File

@ -17,5 +17,7 @@ markdown==3.6
markupsafe==2.1.5
# via dragonglass
# via jinja2
pygments==2.18.0
# via dragonglass
pyyaml==6.0.1
# via dragonglass

View File

@ -503,9 +503,21 @@ def create_markdown_parser(context: Context) -> markdown.Markdown:
Returns:
markdown.Markdown: The new Markdown parser.
"""
return markdown.Markdown(extensions=[MetaStripper(),
extconfig: dict[str, Any] = {
'codehilite': {
'linenums': False,
'guess_lang': False,
'noclasses': False,
'use_pygments': True,
'lang_prefix': 'language'
}
}
return markdown.Markdown(extensions=['fenced_code',
'codehilite',
MetaStripper(),
ObsidianComments(),
ObsidianStyleFootnotes(SUPERSCRIPT_TEXT='[{}]', SEPARATOR='-'),
ObsidianImages(context),
ObsidianLinks(context),
ObsidianInlines()])
ObsidianInlines()],
extension_configs=extconfig)