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 background: transparent url("/dirty-shade.png") repeat-x 0 0;
95 .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 {
99 .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 {
103 .markdown-body h1+p, .markdown-body h2+p, .markdown-body h3+p, .markdown-body h4+p, .markdown-body h5+p, .markdown-body h6+p {
106 .markdown-body li p.first {
107 display: inline-block;
109 .markdown-body ul, .markdown-body ol {
112 .markdown-body ul.no-list, .markdown-body ol.no-list {
113 list-style-type: none;
116 .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 {
119 .markdown-body ul li p:last-of-type, .markdown-body ol li p:last-of-type {
122 .markdown-body ul ul, .markdown-body ul ol, .markdown-body ol ol, .markdown-body ol ul {
128 .markdown-body dl dt {
135 .markdown-body dl dt:first-child {
138 .markdown-body dl dt>:first-child {
141 .markdown-body dl dt>:last-child {
144 .markdown-body dl dd {
148 .markdown-body dl dd>:first-child {
151 .markdown-body dl dd>:last-child {
154 .markdown-body blockquote {
155 border-left: 4px solid #DDD;
159 .markdown-body blockquote>:first-child {
162 .markdown-body blockquote>:last-child {
165 .markdown-body table th {
168 .markdown-body table th, .markdown-body table td {
169 border: 1px solid #ccc;
172 .markdown-body table tr {
173 border-top: 1px solid #ccc;
174 background-color: #fff;
176 .markdown-body table tr:nth-child(2n) {
177 background-color: #f8f8f8;
181 -moz-box-sizing: border-box;
182 box-sizing: border-box;
184 .markdown-body span.frame {
188 .markdown-body span.frame>span {
189 border: 1px solid #ddd;
197 .markdown-body span.frame span img {
201 .markdown-body span.frame span span {
207 .markdown-body span.align-center {
212 .markdown-body span.align-center>span {
218 .markdown-body span.align-center span img {
222 .markdown-body span.align-right {
227 .markdown-body span.align-right>span {
233 .markdown-body span.align-right span img {
237 .markdown-body span.float-left {
243 .markdown-body span.float-left span {
246 .markdown-body span.float-right {
252 .markdown-body span.float-right>span {
258 .markdown-body code, .markdown-body tt {
261 border: 1px solid #eaeaea;
262 background-color: #f8f8f8;
265 .markdown-body code {
268 .markdown-body pre>code {
273 background: transparent;
275 .markdown-body .highlight pre, .markdown-body pre {
276 background-color: #f8f8f8;
277 border: 1px solid #ccc;
284 .markdown-body pre code, .markdown-body pre tt {
287 background-color: transparent;
291 sys
.stdout
.write(HtmlFormatter(style
='pastie').get_style_defs('.highlight'))
295 sys
.stdout
.write("<div class='markdown-body'>")
297 # Note: you may want to run this through bleach for sanitization
298 markdown
.markdownFromFile(
299 output_format
="html5",
301 "markdown.extensions.fenced_code",
302 "markdown.extensions.codehilite",
303 "markdown.extensions.tables",
304 TocExtension(anchorlink
=True)],
306 "markdown.extensions.codehilite":{"css_class":"highlight"}
})
307 sys
.stdout
.write("</div>")