5 from pygments
.formatters
import HtmlFormatter
6 from markdown
.extensions
.toc
import TocExtension
7 sys
.stdin
= io
.TextIOWrapper(sys
.stdin
.buffer, encoding
='utf-8')
8 sys
.stdout
= io
.TextIOWrapper(sys
.stdout
.buffer, encoding
='utf-8')
16 .markdown-body>*:first-child {
17 margin-top: 0 !important;
19 .markdown-body>*:last-child {
20 margin-bottom: 0 !important;
22 .markdown-body a.absent {
25 .markdown-body a.anchor {
35 .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
39 -webkit-font-smoothing: antialiased;
43 .markdown-body h1 .mini-icon-link, .markdown-body h2 .mini-icon-link, .markdown-body h3 .mini-icon-link, .markdown-body h4 .mini-icon-link, .markdown-body h5 .mini-icon-link, .markdown-body h6 .mini-icon-link {
47 .markdown-body h1:hover a.anchor, .markdown-body h2:hover a.anchor, .markdown-body h3:hover a.anchor, .markdown-body h4:hover a.anchor, .markdown-body h5:hover a.anchor, .markdown-body h6:hover a.anchor {
48 text-decoration: none;
54 .markdown-body h1:hover a.anchor .mini-icon-link, .markdown-body h2:hover a.anchor .mini-icon-link, .markdown-body h3:hover a.anchor .mini-icon-link, .markdown-body h4:hover a.anchor .mini-icon-link, .markdown-body h5:hover a.anchor .mini-icon-link, .markdown-body h6:hover a.anchor .mini-icon-link {
55 display: inline-block;
57 div#cgit .markdown-body h1 a.toclink, div#cgit .markdown-body h2 a.toclink, div#cgit .markdown-body h3 a.toclink, div#cgit .markdown-body h4 a.toclink, div#cgit .markdown-body h5 a.toclink, div#cgit .markdown-body h6 a.toclink {
60 .markdown-body h1 tt, .markdown-body h1 code, .markdown-body h2 tt, .markdown-body h2 code, .markdown-body h3 tt, .markdown-body h3 code, .markdown-body h4 tt, .markdown-body h4 code, .markdown-body h5 tt, .markdown-body h5 code, .markdown-body h6 tt, .markdown-body h6 code {
69 border-bottom: 1px solid #ccc;
85 .markdown-body p, .markdown-body blockquote, .markdown-body ul, .markdown-body ol, .markdown-body dl, .markdown-body table, .markdown-body pre {
89 border: 2px solid #ccc;
91 .markdown-body>h2:first-child, .markdown-body>h1:first-child, .markdown-body>h1:first-child+h2, .markdown-body>h3:first-child, .markdown-body>h4:first-child, .markdown-body>h5:first-child, .markdown-body>h6:first-child {
95 .markdown-body a:first-child h1, .markdown-body a:first-child h2, .markdown-body a:first-child h3, .markdown-body a:first-child h4, .markdown-body a:first-child h5, .markdown-body a:first-child h6 {
99 .markdown-body h1+p, .markdown-body h2+p, .markdown-body h3+p, .markdown-body h4+p, .markdown-body h5+p, .markdown-body h6+p {
102 .markdown-body li p.first {
103 display: inline-block;
105 .markdown-body ul, .markdown-body ol {
108 .markdown-body ul.no-list, .markdown-body ol.no-list {
109 list-style-type: none;
112 .markdown-body ul li>:first-child, .markdown-body ul li ul:first-of-type, .markdown-body ul li ol:first-of-type, .markdown-body ol li>:first-child, .markdown-body ol li ul:first-of-type, .markdown-body ol li ol:first-of-type {
115 .markdown-body ul li p:last-of-type, .markdown-body ol li p:last-of-type {
118 .markdown-body ul ul, .markdown-body ul ol, .markdown-body ol ol, .markdown-body ol ul {
124 .markdown-body dl dt {
131 .markdown-body dl dt:first-child {
134 .markdown-body dl dt>:first-child {
137 .markdown-body dl dt>:last-child {
140 .markdown-body dl dd {
144 .markdown-body dl dd>:first-child {
147 .markdown-body dl dd>:last-child {
150 .markdown-body blockquote {
151 border-left: 4px solid #DDD;
155 .markdown-body blockquote>:first-child {
158 .markdown-body blockquote>:last-child {
161 .markdown-body table th {
164 .markdown-body table th, .markdown-body table td {
165 border: 1px solid #ccc;
168 .markdown-body table tr {
169 border-top: 1px solid #ccc;
170 background-color: #fff;
172 .markdown-body table tr:nth-child(2n) {
173 background-color: #f8f8f8;
177 -moz-box-sizing: border-box;
178 box-sizing: border-box;
180 .markdown-body span.frame {
184 .markdown-body span.frame>span {
185 border: 1px solid #ddd;
193 .markdown-body span.frame span img {
197 .markdown-body span.frame span span {
203 .markdown-body span.align-center {
208 .markdown-body span.align-center>span {
214 .markdown-body span.align-center span img {
218 .markdown-body span.align-right {
223 .markdown-body span.align-right>span {
229 .markdown-body span.align-right span img {
233 .markdown-body span.float-left {
239 .markdown-body span.float-left span {
242 .markdown-body span.float-right {
248 .markdown-body span.float-right>span {
254 .markdown-body code, .markdown-body tt {
257 border: 1px solid #eaeaea;
258 background-color: #f8f8f8;
261 .markdown-body code {
264 .markdown-body pre>code {
269 background: transparent;
271 .markdown-body .highlight pre, .markdown-body pre {
272 background-color: #f8f8f8;
273 border: 1px solid #ccc;
280 .markdown-body pre code, .markdown-body pre tt {
283 background-color: transparent;
287 sys
.stdout
.write(HtmlFormatter(style
='pastie').get_style_defs('.highlight'))
291 sys
.stdout
.write("<div class='markdown-body'>")
293 # Note: you may want to run this through bleach for sanitization
294 markdown
.markdownFromFile(
295 output_format
="html5",
297 "markdown.extensions.fenced_code",
298 "markdown.extensions.codehilite",
299 "markdown.extensions.tables",
300 "markdown.extensions.sane_lists",
301 TocExtension(anchorlink
=True)],
303 "markdown.extensions.codehilite":{"css_class":"highlight"}
})
304 sys
.stdout
.write("</div>")