-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.html
117 lines (96 loc) · 3.47 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<title>mdthtml</title>
<meta name="author" content="Chris Magyar">
<meta name="description" content="Commonmark-plus flavored markdown to html parser.">
<link rel="stylesheet" href="css/main.css">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width">
<link rel="icon" href="data:,">
</head>
<body>
<p>Markdown parser with extras built in. This project is a bunch of additions to
<a href="https://github.com/executablebooks/markdown-it-py" target="_blank">markdown-it-py</a>. It's kind
of hacky right now, but it works alright for my purposes.</p>
<h2 id="Installation">Installation</h2>
<p>This is beta-alpha right now so it ain't on PyPI yet. Clone this repo and
build/run/install manually.</p>
<p>Build python package:</p>
<pre><code><span class="prompt">$ </span>python -m build
</pre></code>
<p>Build package, install in a virtual environment, and run all tests:</p>
<pre><code><span class="prompt">$ </span>make test
</pre></code>
<h2 id="Python API Usage">Python API Usage</h2>
<pre><code class="language-python">from mdthtml import MarkdownHTML
text = ("""---
title: Test Document
author: mags
---
# Heading
Some code:
sudo mount /dev/sda2 /mnt/nas
""")
mdhtml = MarkdownHTML()
mdhtml.parse(text)
print(mdhtml.html)
</code></pre>
<h2 id="Command Line Usage">Command Line Usage</h2>
<p>Accepts stdin and/or a list of files. Outputs to stdout or a single file.</p>
<pre><code>mdthtml [OPTION...] [FILE...]
</pre></code>
<h3 id="Options">Options</h3>
<pre><code>-c, --css <PATH>
Add link to css stylesheet. PATH does not necessarily need to exist.
-R, --relative
Calculate css path relative to first FILE.
-f, --template-file <FILE>
Template file.
-o, --output <FILE>
Output to file.
-O, --auto
Automatically name output file based on last file supplied.
-t, --title <TITLE>
Title to include in head, overrides any metadata in document.
-B, --body-only
Output html body content only. ('{content}' as template string)
-M, --meta-only
Output html meta content only. ('{metatdata}' as template string)
-J, --json
Output json.
-T, --tree
Output token tree.
-Y, --yes
Overwrite output file.
-h
Print short help.
-H, --help
Print help.
</pre></code>
<h2 id="Features">Features</h2>
<p>Commonmark standard (gfm tables) as parsed by <em>markdown-it-py</em> plus some hacky
additions:</p>
<ul>
<li>add id tags to every heading element</li>
<li>parse front-matter for metadata (without <em>front_matter</em> plugin)</li>
<li>customized code blocks (make PS1 prompt its own span for styling)</li>
</ul>
<h3 id="Features Roadmap">Features Roadmap</h3>
<ul>
<li>table of contents (customized names, not just a copy of heading content)</li>
<li>banner ascii figlet content</li>
<li>syntax highlighting</li>
<li>images, galleries</li>
</ul>
<h3 id="Ideas/Directions">Ideas/Directions</h3>
<p>I'd like to make any additional markdown syntax I implement also be as
compatible as possible with more standard markdown parsers (e.g. github's
markdown parser). Then one won't have to write different/separate markdown for
these platforms. One simple way to do this is by using html comments to add
content/metadata.</p>
<p>I could write plugins and/or parse content after/before passing to
markdown-it-py. Writing plugins is probably the way to go, although some things
may not be possible with plugins alone.</p>
</body>
</html>