Fix pandoc filter.
And add a script that helps to run pandoc with appropriate command line flags.
This commit is contained in:
parent
6b82dff8f3
commit
924f373a2f
2 changed files with 18 additions and 9 deletions
9
Doc/Manual/markdown_to_html.sh
Executable file
9
Doc/Manual/markdown_to_html.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Usage: markdown_to_html <Language>"
|
||||
echo "-- Example: markdown_to_html Javascript"
|
||||
else
|
||||
pandoc -f markdown -t json $1.md | ./pandoc_filter.py | pandoc -f json -t html -s --template pandoc_template.html -o $1.html
|
||||
fi
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Pandoc filter that changes pandoc default HTML output for codeblocks
|
||||
|
|
@ -24,16 +24,16 @@ the_title = ""
|
|||
def codeblocks(key, value, format, meta):
|
||||
if key == 'CodeBlock':
|
||||
[[id, classes, kvs], contents] = value
|
||||
if format == "html" or format == "html5":
|
||||
newcontents = [html('<pre>\n' + contents + '</pre>')]
|
||||
|
||||
if len(classes) == 0:
|
||||
if contents.startswith("$"):
|
||||
classes.append("shell")
|
||||
else:
|
||||
classes.append("code")
|
||||
newcontents = [html('<pre>\n' + contents + '</pre>')]
|
||||
|
||||
return Div([id, classes, kvs], newcontents)
|
||||
if len(classes) == 0:
|
||||
if contents.startswith("$"):
|
||||
classes.append("shell")
|
||||
else:
|
||||
classes.append("code")
|
||||
|
||||
return Div([id, classes, kvs], newcontents)
|
||||
if key == 'Header':
|
||||
if value[0] == 1:
|
||||
the_title = stringify(value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue