Show More
@@ -1346,41 +1346,6 b' def rst2simplehtml(infile):' | |||||
1346 |
|
1346 | |||
1347 | return newfname |
|
1347 | return newfname | |
1348 |
|
1348 | |||
1349 |
|
||||
1350 | def md2html(infile): |
|
|||
1351 | """Convert a markdown file to simplified html suitable for blogger. |
|
|||
1352 |
|
||||
1353 | """ |
|
|||
1354 | html = markdown(open(infile).read()) |
|
|||
1355 |
|
||||
1356 | from pygments.formatters import HtmlFormatter |
|
|||
1357 | css = HtmlFormatter().get_style_defs('.highlight') |
|
|||
1358 |
|
||||
1359 | template = """ |
|
|||
1360 | <!DOCTYPE HTML> |
|
|||
1361 | <html> |
|
|||
1362 |
|
||||
1363 | <head> |
|
|||
1364 | <title>{infile}</title> |
|
|||
1365 | <style type="text/css"> |
|
|||
1366 | {css} |
|
|||
1367 | </style> |
|
|||
1368 |
|
||||
1369 | </head> |
|
|||
1370 |
|
||||
1371 | <body> |
|
|||
1372 | {html} |
|
|||
1373 | </body> |
|
|||
1374 |
|
||||
1375 | </html> |
|
|||
1376 | """ |
|
|||
1377 | full_html = template.format(**locals()) |
|
|||
1378 | newfname = os.path.splitext(infile)[0] + '.html' |
|
|||
1379 | with open(newfname, 'w') as f: |
|
|||
1380 | f.write(full_html) |
|
|||
1381 |
|
||||
1382 | return newfname |
|
|||
1383 |
|
||||
1384 | #----------------------------------------------------------------------------- |
|
1349 | #----------------------------------------------------------------------------- | |
1385 | # Cell-level functions -- similar to IPython.nbformat.v3.rwbase functions |
|
1350 | # Cell-level functions -- similar to IPython.nbformat.v3.rwbase functions | |
1386 | # but at cell level instead of whole notebook level |
|
1351 | # but at cell level instead of whole notebook level |
General Comments 0
You need to be logged in to leave comments.
Login now