-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test using a markdownit renderer
- Loading branch information
1 parent
097cc09
commit 69ae7f8
Showing
3 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from markdown_it import MarkdownIt | ||
from mdit_py_plugins.dollarmath import dollarmath_plugin | ||
import sys | ||
from pathlib import Path | ||
from jinja2 import Environment, FileSystemLoader, select_autoescape | ||
|
||
import html | ||
# can be removed if we make `print_docs` an installable module | ||
sys.path.append(str(Path(__file__).parent.parent)) | ||
|
||
md = ( | ||
MarkdownIt('commonmark' ,{'breaks':True,'html':True}) | ||
.use(dollarmath_plugin) | ||
.enable('table') | ||
) | ||
|
||
env = Environment( | ||
loader=FileSystemLoader('templates', 'utf-8'), | ||
autoescape=select_autoescape(['html', 'xml']) | ||
) | ||
|
||
def write_pure_md_file(source, dest, name): | ||
with open(source) as infile: | ||
body = md.render(infile.read()) | ||
|
||
with open(dest, 'w') as out: | ||
out.write(env.get_template('pure_md.j2').render( | ||
active_path = '', | ||
name = name, | ||
body = body, | ||
)) | ||
|
||
|
||
write_pure_md_file('test/latex.md', 'latex.html', 'LaTeX test') |