html.xonsh/readFile.py

27 lines
746 B
Python
Executable File

#!/usr/bin/python
import markdown2
from bs4 import BeautifulSoup as bs
# Only do the <body> tag
class readMarkdown():
mdFile = ""
def __init__(self, mdFile):
self.mdFile = mdFile
outLi = []
def markdown(self):
file = open(self.mdFile, 'r')
outStr = ""
#outStr = bs(markdown.markdown(str(outLi[1]), tab_length=4, output_format="html", extensions=['codehilite', 'tables']))
outStr = markdown2.markdown(str(file.read()), extras=['fenced-code-blocks', 'metadata'])
file.close()
return(outStr)
def __str__(self):
return(str(self.markdown()))
# might want to find a way to diff html from a file and readMarkdown()'s output if I want to update pages