")
if(self.date):
self.doc.append("
Date: {date}
".format(date=self.date))
if(self.author):
self.doc.append("
Author: {author}
".format(author=self.author))
self.doc.append("
Created: {date}
".format(date=str(datetime.datetime.now())))
self.doc.append("
")
def BuildDoc(self):
out = '\n'.join(self.pre) + '\n' + '\n'.join(self.doc) + '\n'
return out
def FinishDocCustom(self):
self.Postamble()
self.doc.append("\n")
self.fs.write(self.BuildDoc())
class HtmlExportHelper(exp.OrgExportHelper):
def __init__(self,view,index):
super(HtmlExportHelper,self).__init__(view,index)
def CustomBuildHead(self):
highlight = exp.GetGlobalOption(self.file,"HTML_HIGHLIGHT","HtmlHighlight","zenburn").lower()
#self.doc.AddInlineStyle(GetHighlightJsCss(highlight))
self.doc.AddStyle('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/default.min.css')
self.doc.AddInlineStyle(GetCollapsibleCss())
self.doc.AddInlineStyle(GetStyleData(self.doc.style, self.file))
# Export the entire file using our internal exporter
class OrgExportFileOrgHtmlCommand(sublime_plugin.TextCommand):
def OnDoneSourceBlockExecution(self):
# Reload if necessary
self.file = db.Get().FindInfo(self.view)
doc = None
self.style = exp.GetGlobalOption(self.file,"HTML_STYLE","HtmlStyle","blocky").lower()
log.log(51,"EXPORT STYLE: " + self.style)
try:
outputFilename = exp.ExportFilename(self.view,".html", self.suffix)
doc = HtmlDoc(outputFilename, self.file)
doc.style = self.style
self.helper = HtmlExportHelper(self.view, self.index)
self.helper.Run(outputFilename, doc)
finally:
evt.EmitIf(self.onDone)
def run(self,edit, onDone=None, index=None, suffix=""):
self.file = db.Get().FindInfo(self.view)
self.onDone = onDone
self.suffix = suffix
if(index != None):
self.index = index
else:
self.index = None
if(self.file is None):
log.error("Not an org file? Cannot build reveal document")
evt.EmitIf(onDone)
return
if(sets.Get("htmlExecuteSourceOnExport",True)):
self.view.run_command('org_execute_all_source_blocks',{"onDone":evt.Make(self.OnDoneSourceBlockExecution),"amExporting": True})
else:
self.OnDoneSourceBlockExecution()
def sync_up_on_closed():
notice.Get().BuildToday()
class OrgDownloadHighlighJs(sublime_plugin.TextCommand):
def run(self,edit):
log.info("Trying to download highlightjs")
import OrgExtended.orgutil.webpull as wp
wp.download_highlightjs()
class OrgExportSubtreeAsOrgHtmlCommand(sublime_plugin.TextCommand):
def OnDone(self):
evt.EmitIf(self.onDone)
def run(self,edit,onDone=None):
self.onDone = onDone
n = db.Get().AtInView(self.view)
if(n == None):
log.error(" Failed to find node! Subtree cannot be exported!")
return
index = 0
for i in range(0,len(n.env._nodes)):
if(n == n.env._nodes[i]):
index = i
if(index == 0):
log.error(" Failed to find node in file! Something is wrong. Cannot export subtree!")
return
self.view.run_command('org_export_file_org_html', {"onDone": evt.Make(self.OnDone), "index": index, "suffix":"_subtree"})
================================================
FILE: orghtmlexporter.py
================================================
import sublime
import sublime_plugin
import datetime
import re
import regex
from pathlib import Path
import os
import fnmatch
import OrgExtended.orgparse.node as node
from OrgExtended.orgparse.sublimenode import *
import OrgExtended.orgutil.util as util
import OrgExtended.orgutil.navigation as nav
import OrgExtended.orgutil.template as templateEngine
import logging
import sys
import traceback
import OrgExtended.orgfolding as folding
import OrgExtended.orgdb as db
import OrgExtended.asettings as sets
import OrgExtended.orgcapture as capture
import OrgExtended.orgproperties as props
import OrgExtended.orgexporter as exp
import OrgExtended.pymitter as evt
import OrgExtended.orgplist as plist
import OrgExtended.orgsourceblock as src
import yaml
import sys
import subprocess
import html
log = logging.getLogger(__name__)
#
RE_COMMENT_TAG = re.compile(r"^\s*[<][!][-][-]\s+(?P