def HTML(src, target=None, standalone=True): """ Builds an HTML file from a Markdown source. Arguments: src -- Markdown source file. Should be in utf-8 encoding. Keyword arguments: target -- HTML target file or None to skip saving. (default=None) standalone -- Indicates whether a full HTML5 document should be generated, which embeds all content, or whether the document should be rendered without <head> and <body> tags, etc. Returns: The HTML file as a unicode string. """ md = MD(src) # Count words print u'Document statistics:' print u'Word count: %d' % len(md.split()) print u'Character count: %d' % len(md) # And finally convert the Markdown to HTML pd = Pandoc(css=css, csl=csl, template=html5Ref, standalone=standalone, \ verbose=True) html = pd.parse(md) for flt in htmlFilters: fltFunc = getattr(HTMLFilter, flt) html = fltFunc(html) if target != None: open(target, u'w').write(html.encode(u'utf-8')) print u'Done!' return html
def HTML(src, target=None, standalone=True): """ desc: | Builds an HTML file from a Markdown source. %-- constant: arg_src: The Markdown source. If it is a path to an existing file, the contents of this file are read. Otherwise, the string itself it used. Should be in utf-8 encoding. --% arguments: src: desc: "%arg_src" type: [str, unicode] keywords: target: desc: The name of an HTML target file or None to skip saving. type: [str, unicode, NoneType] standalone: desc: Indicates whether a full HTML5 document should be generated, which embeds all content, or whether the document should be rendered without `<head>` and `<body>` tags, etc. type: bool returns: desc: The HTML file as a unicode string. type: unicode """ md = MD(src) # Count words print(u'Document statistics:') print(u'Word count: %d' % len(md.split())) print(u'Character count: %d' % len(md)) # And finally convert the Markdown to HTML pd = Pandoc(css=css, csl=csl, template=html5Ref, standalone=standalone, \ verbose=True) html = pd.parse(md) for flt in htmlFilters: fltFunc = getattr(HTMLFilter, flt) html = fltFunc(html) if target != None: open(target, u'wb').write(safe_encode(html)) print(u'Done!') return html
def DOCX(src, target): """ Builds a DOCX file from a Markdown source. Arguments: src -- Markdown source file. Should be in utf-8 encoding. target -- DOCX target file. """ global figureTemplate tmp = figureTemplate figureTemplate = u'markdown' md = MD(src) pd = Pandoc(csl=csl, verbose=True) pd.docx(md, target, docxRef=docxRef) figureTemplate = tmp
def ODT(src, target): """ Builds an ODT file from a Markdown source. Arguments: src -- Markdown source file. Should be in utf-8 encoding. target -- ODT target file. """ global figureTemplate tmp = figureTemplate figureTemplate = u'odt' md = MD(src) pd = Pandoc(csl=csl, verbose=True) pd.odt(md, target, odtRef=odtRef) ODTFixer(verbose=True).fix(target) figureTemplate = tmp
def DOCX(src, target): """ desc: Builds a DOCX file from a Markdown source. arguments: src: desc: "%arg_src" type: [str, unicode] target: desc: The name of a DOCX target file. type: [str, unicode] """ global figureTemplate tmp = figureTemplate figureTemplate = u'markdown' md = MD(src) pd = Pandoc(csl=csl, verbose=True) pd.docx(md, target, docxRef=docxRef) figureTemplate = tmp
def ODT(src, target): """ desc: Builds an ODT file from a Markdown source. arguments: src: desc: "%arg_src" type: [str, unicode] target: desc: The name of an ODT target file. type: [str, unicode] """ global figureTemplate tmp = figureTemplate figureTemplate = u'odt' md = MD(src) pd = Pandoc(csl=csl, verbose=True) pd.odt(md, target, odtRef=odtRef) ODTFixer(verbose=True).fix(target) figureTemplate = tmp