Skip to content

Commit

Permalink
test: cli
Browse files Browse the repository at this point in the history
  • Loading branch information
shaokeyibb committed Jul 8, 2024
1 parent bb21b7d commit 339e6c0
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions python-markdown-extension/test/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import argparse
from argparse import FileType
import markdown

from pymdownx.emoji import to_svg
from pymdownx.slugs import uslugify
from pymdownx.arithmatex import fence_mathjax_format

parser = argparse.ArgumentParser("cli")
parser.add_argument(
"file", help="Markdown file to be rendered", type=FileType(encoding="utf-8")
)
args = parser.parse_args()

result = markdown.markdown(
args.file.read(),
extensions=[
"document-offsets-injection",
"admonition",
"def_list",
"footnotes",
"meta",
"toc",
"pymdownx.arithmatex",
"pymdownx.caret",
"pymdownx.critic",
"pymdownx.details",
"pymdownx.emoji",
"pymdownx.highlight",
"pymdownx.inlinehilite",
"pymdownx.keys",
"pymdownx.magiclink",
"pymdownx.mark",
"pymdownx.snippets",
"pymdownx.progressbar",
"pymdownx.smartsymbols",
"pymdownx.superfences",
"pymdownx.tasklist",
"pymdownx.tilde",
"pymdownx.tabbed",
],
extension_configs={
"toc": {
"permalink": "",
"slugify": uslugify,
},
"pymdownx.arithmatex": {
"generic": True,
},
"pymdownx.emoji": {
"emoji_generator": to_svg,
},
"pymdownx.highlight": {
"linenums": True,
},
"pymdownx.snippets": {
"check_paths": True,
},
"pymdownx.superfences": {
"custom_fences": [
{
"name": "math",
"class": "arithmatex",
"format": fence_mathjax_format,
},
],
},
"pymdownx.tasklist": {
"custom_checkbox": True,
},
"pymdownx.tabbed": {
"alternate_style": True,
},
},
)

print(result)

0 comments on commit 339e6c0

Please sign in to comment.