PK ! Z pandoc_styles/__init__.pyfrom .utils import (change_dir, file_read, file_write, make_list, run_process,
expand_directories)
from .flight_scripts import run_postflight_script, run_preflight_script
from .filter import * # pylint: disable=W0401
from .main import PandocStyles
PK ! k:a $ pandoc_styles/config_dir/config.yaml---
# only needed, if pandoc is not in PATH
pandoc-path:
# path to python for scripts. Only needed, if your operating system needs this.
# for example: on windows with the standard python installation use "py".
python-path: python
...
PK ! \ ( pandoc_styles/config_dir/css/default.cssbody {
max-width: 800px;
grid-column-gap: 3em;
padding-top: 2em;
font-family: "Noto Serif", serif;
font-size: 10pt;
line-height: "1.2";
text-align: justify;
margin: 3em auto 0 auto;
}
.content {
margin: 1em;
padding-bottom: 2em;
}
@media only screen and (min-width: 600px) {
body {
font-size: 12pt;
line-height: "1.5";
-webkit-box-shadow: 1px 4px 14px #888;
box-shadow: 1px 4px 14px #888;
}
.content {
margin: 1em 3em 3em 3em;
}
}
header {
text-align: center;
}
h1 {
font-family: "Noto Sans", sans-serif;
margin-top: 1em;
margin-bottom: 1em;
font-size: 1.5em;
text-align: left;
font-weight: bold;
page-break-before: always;
text-indent: 0;
}
h2 {
font-size: 1.3em;
}
h3 {
font-size: 1.2em;
page-break-before: auto;
}
p {
margin: 0;
text-indent: 0;
}
p + p {
margin-top: 1em;
}
a {
color: inherit;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
}
a .footnoteRef {
vertical-align: super;
}
*[id^='fn']:target {
background-color: #ffa;
}
.math {
font-family: "Noto Serif", serif;
font-size: 0.9em;
}
blockquote {
font-style: italic;
}
.citation {
font-style: normal;
}
section.footnotes {
margin-top: 2em;
}
code {
font-family: "Fira Code", monospace;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual;
-webkit-font-feature-settings: "calt" 1;
font-feature-settings: "calt" 1;
font-size: 0.9em;
}
figure {
text-align: center;
margin: 1em 0;
max-width: 100%;
max-height: 100%;
page-break-inside: avoid;
clear: both;
}
figure img {
max-height: 100%;
max-width: 100%;
}
figcaption {
text-indent: 0;
text-align: center;
font-style: italic;
padding-left: 1em;
padding-right: 1em;
}
ol.toc {
padding: 0;
margin-left: 1em;
}
ol.toc li {
list-style-type: none;
margin: 0;
padding: 0;
}
em, em em em, em em em em em {
font-style: italic;
}
em em, em em em em {
font-style: normal;
}
.date {
font-family: "Oswald", sans-serif;
margin-top: 1em;
margin-bottom: 3em;
text-indent: 0em;
font-size: 1.2em;
text-align: center;
}
.author {
font-family: "Oswald", sans-serif;
margin-top: 1em;
text-indent: 0em;
font-size: 1.5em;
text-align: center;
}
.main {
font-family: "Oswald", sans-serif;
margin-top: 2em;
text-indent: 0em;
font-size: 1.6em;
font-weight: bold;
text-align: center;
}
.title {
font-family: "Oswald", sans-serif;
text-indent: 0em;
font-size: 1.6em;
font-weight: bold;
text-align: center;
}
.subtitle {
font-family: "Oswald", sans-serif;
margin-top: 1em;
text-indent: 0em;
font-size: 1.4em;
font-style: italic;
text-align: center;
}
#sidebar {
right: 1em;
top: 3em;
z-index: 1;
margin: 0;
text-align: left;
padding: 0;
position: fixed;
overflow-y: auto;
overflow-x: hidden;
max-width: 350px;
max-height: 95%;
font-size: 10pt;
}
#sidebar ul {
display: none;
width: 100%;
list-style: none;
margin: 0;
background: #FFFFFF;
}
#sidebar ul li {
margin-right: 4em;
}
#sidebar ul li a {
display: block;
padding: 0.3em;
background: #FFFFFF;
color: #000000;
text-decoration: none;
}
#sidebar ul li a:hover {
color: #FFFFFF;
background: #555;
}
#sidebar input.trigger {
position: absolute;
top: -9999px;
left: -9999px;
}
#sidebar input.trigger:checked ~ ul, #sidebar input.trigger:checked ~ ul li ul {
display: block !important;
}
#sidebar label {
position: fixed;
right: 0.5em;
top: .2em;
width: 1.2em;
height: 1.2em;
text-align: center;
font-size: 2em;
background: #FFFFFF;
color: #000000;
}
#sidebar label:after {
content: "\2261";
}
#sidebar label:hover {
color: #FFFFFF;
background: #555;
}
PK ! .Ɔ , pandoc_styles/config_dir/filter/alignment.pyfrom pandoc_styles import run_transform_filter
def latex(self):
if "left" in self.classes:
style = "flushleft"
elif "right" in self.classes:
style = "flushright"
else:
style = "center"
return (f'\\begin{{{style}}}\n'
f'{self.convert_text()}\n'
f'\\end{{{style}}}\n')
def html(self):
if "left" in self.classes:
style = "left"
elif "right" in self.classes:
style = "right"
else:
style = "center"
return (f'
\n'
f'{self.convert_text()}\n'
f'
')
if __name__ == "__main__":
run_transform_filter(["align"], latex, html)
PK ! Zx 0 pandoc_styles/config_dir/filter/custom_styles.pyfrom pandoc_styles import run_transform_filter
def latex(self):
style_pdf = self.classes[1] if len(self.classes) == 2 else self.attributes.get("pdf", "")
return (f'\\begin{{{style_pdf}}}\n'
f'{self.convert_text()}\n'
f'\\end{{{style_pdf}}}\n')
def html(self):
style_epub = self.classes[1] if len(self.classes) == 2 \
else self.attributes.get("epub", "") or self.attributes.get("html", "")
return (f'\n'
f'{self.convert_text()}\n'
f'
')
if __name__ == "__main__":
run_transform_filter(["custom"], latex, html, '{text}')
PK ! L + pandoc_styles/config_dir/filter/epigraph.pyfrom pandoc_styles import run_transform_filter
def latex(self):
author = self.attributes["author"] if "author" in self.attributes else ""
return (f'\\dictum[{author}]'
f'{{{self.convert_text()}}}'
f'\n\\par\n\\vspace{{\\baselineskip}}\n'
f'\\par\n\\noindent\n')
def html(self):
author = f'\n{self.attributes["author"]}
' \
if "author" in self.attributes else ""
return (f'\n'
f'{self.convert_text()}'
f'{author}\n
')
if __name__ == "__main__":
run_transform_filter(["epigraph"], latex, html)
PK ! Xb * pandoc_styles/config_dir/filter/include.py"""
Includes other markdown files given in a Code block with the class "include. One
file path per line.
"""
from os.path import isfile
from pandoc_styles import run_pandoc_styles_filter, CodeBlock, file_read
def include(self):
new = "\n".join(file_read(line) for line in self.text.splitlines()
if not line[0] == "#" and isfile(line))
return new
if __name__ == "__main__":
run_pandoc_styles_filter(include, CodeBlock, "include")
PK ! G4~ ~ + pandoc_styles/config_dir/filter/new_page.pyfrom pandoc_styles import run_transform_filter
def latex(self):
if "odd-page" in self.classes:
return r"\cleardoublepage"
return r"\clearpage"
if __name__ == "__main__":
run_transform_filter(["new_page", "new-page"],
latex,
'
',
"\n----\n")
PK ! +mOP + pandoc_styles/config_dir/filter/noindent.pyfrom pandoc_styles import run_transform_filter
if __name__ == "__main__":
run_transform_filter(
["noindent", "no-indent", "no_indent"],
'\\noindent\n{text}\n',
'\n{text}\n
')
PK ! " 0 pandoc_styles/config_dir/filter/numbered_code.pyfrom pandoc_styles import run_pandoc_styles_filter, CodeBlock
def numbered(self):
self.classes.append("numberLines")
if __name__ == "__main__":
run_pandoc_styles_filter(numbered, CodeBlock)
PK ! `+ ' pandoc_styles/config_dir/filter/poem.py"""
Formats poems. The poem has to be inside a Code block with the class "poem".
There are many optional attributes that can be set:
author: The author of the poem
title: The title of the poem
altverse: true or false
poemlines: true or false
In addition you can set a style. Either global by adding the "quote-style" field to
the metadata style definition or by setting the style as a class in the code block.
The three styles are: "bottom", "top" and "one-line".
"""
import re
from pandoc_styles import run_transform_filter, strip_html_tag
def all_formats(self):
self.style = self.get_metadata("poem-style", "bottom")
if "top" in self.classes:
self.style = "top"
elif "bottom" in self.classes:
self.style = "bottom"
elif "one-line" in self.classes:
self.style = "one-line"
def latex(self):
new = []
if self.style == "top" and "title" in self.attributes:
new.extend([r"\poemtitle*{", self.attributes["title"], "}\n"])
if "versewidth" in self.attributes:
new.extend([r"\settowidth{\versewidth}{", self.attributes["versewidth"],
"}", "\n", r"\begin{verse}[\versewidth]", "\n"])
elif "no_versewidth" in self.classes:
new.extend([r'\begin{verse}', "\n"])
else:
lst = []
for line in self.text.split("\n"):
if line and line[0] not in ["!", "[", "{"]:
lst.append((len(line), line))
_, max_line = max(lst)
new.extend([r"\settowidth{\versewidth}{", max_line,
"}\n", r"\begin{verse}[\versewidth]", "\n"])
if "poemlines" in self.attributes:
new.extend([r"\poemlines{", self.attributes["poemlines"], "}\n"])
if "altverse" in self.classes:
new.extend([r"\begin{altverse}", "\n"])
for line in self.text.split("\n"):
if line == "":
if "altverse" in self.classes:
new.extend([r"\\!", r"\end{altverse}", "\n\n", r"\begin{altverse}", "\n"])
else:
new.extend([r"\\!", "\n"])
else:
new.extend([self.convert_text(line).strip("\n"), r"\\", "*", "\n"])
new.extend([r"\\!", "\n"])
if self.style == "top" and "author" in self.attributes:
new.extend([r"\hspace*{\fill}", r"\rightskip2em \textit{",
self.attributes["author"], "}\n"])
elif self.style == "one-line" and "author" in self.attributes and\
"title" in self.attributes:
new.extend([r"\hfill \rightskip2em \textit{", self.attributes["author"],
"} --- ", r"\textbf{", self.attributes["title"], "}\n"])
elif self.style != "top":
if "title" in self.attributes and "author" in self.attributes:
new.extend([r"\hspace*{\fill}", r"\rightskip2em \textbf{",
self.attributes["title"], "}", r"\linebreak"])
new.extend([r"\hspace*{\fill}", r"\rightskip2em \textit{",
self.attributes["author"], "}\n"])
elif "author" in self.attributes:
new.extend([r"\hspace*{\fill}", r"\rightskip2em \textit{",
self.attributes["author"], "}\n"])
elif "title" in self.attributes:
new.extend([r"\hspace*{\fill}", r"\rightskip2em \textbf{",
self.attributes["title"], "}\n"])
if "altverse" in self.classes:
new.extend([r"\end{altverse}", "\n"])
if "poemlines" in self.attributes:
new.extend([r"\poemlines{0", "}\n"])
new.append(r"\end{verse}")
new = ''.join(new)
new = re.sub(r'\\\\\*\n\\\\!', '\\\\\!\n', new) # pylint: disable=W1401
return new
def html(self):
new = ['']
if self.style == "top" and "title" in self.attributes:
new.extend(["\n
", self.attributes["title"], "
"])
if self.style == "top" and "author" in self.attributes:
new.extend(["\n
", self.attributes["author"], "
"])
new.extend(['\n
'])
i = 0
for line in self.text.split("\n"):
if line == "":
if "altverse" in self.classes:
i = 1
new.extend(['\n
\n
\n
'])
elif "altverse" in self.classes:
if i % 2 == 0:
new.extend(["\n", self.convert_text(line)])
else:
new.extend(["\n
",
strip_html_tag(self.convert_text(line)), "
"])
else:
new.extend(["\n", self.convert_text(line)])
i += 1
new.extend(['\n
'])
if self.style == "one-line" and "author" in self.attributes and\
"title" in self.attributes:
new.extend(["\n
", self.attributes["author"], " ",
" — ", self.attributes["title"], "
"])
elif self.style != "top":
if "title" in self.attributes:
new.extend(["\n
", self.attributes["title"], "
"])
if "author" in self.attributes:
new.extend(["\n
", self.attributes["author"], "
"])
new.extend(['\n
'])
return new
def other(self):
new = []
if self.style == "top" and "title" in self.attributes:
new.extend(["| __", self.attributes["title"], "__\n"])
if self.style == "top" and "author" in self.attributes:
new.extend(["| _", self.attributes["author"], "_\n"])
if self.style == "top" and ("author" in self.attributes or "title" in self.attributes):
new.extend(["| \n"])
i = 0
for line in self.text.split("\n"):
if line == "":
if "altverse" in self.classes:
i = 1
new.extend(['| ', "\n"])
elif "altverse" in self.classes:
if i % 2 == 0:
new.extend(['| ', line, "\n"])
else:
new.extend(['| ', line, "\n"])
else:
new.extend(['| ', line, "\n"])
i += 1
if self.style == "one-line" and "author" in self.attributes and\
"title" in self.attributes:
new.extend(['| \n| _', self.attributes["author"], '_ --- __',
self.attributes["title"], '__\n'])
elif self.style != "top":
if "title" in self.attributes:
new.extend(['| \n| __', self.attributes["title"], '__\n'])
if "author" in self.attributes:
new.extend(['| \n| _', self.attributes["author"], '_\n'])
new = ''.join(new)
new = re.sub(r'\|\s\|', '|', new, flags=re.MULTILINE)
return new
if __name__ == "__main__":
run_transform_filter(["poem"], latex, html, other, all_formats)
PK ! 8e ( pandoc_styles/config_dir/filter/quote.py"""
Formats quotes with a title and author. The quote has to be inside a Code block with
the class "quote".
There are two optional attributes that can be set:
author: The author of the quote
title: The title/source of the quote
In addition you can set a style. Either global by adding the "quote-style" field to
the metadata style definition or by setting the style as a class in the code block.
The three styles are: "bottom", "top" and "one-line".
"""
from pandoc_styles import run_transform_filter
def all_formats(self):
self.style = self.get_metadata("quote-style", "bottom")
if "top" in self.classes:
self.style = "top"
elif "bottom" in self.classes:
self.style = "bottom"
elif "one-line" in self.classes:
self.style = "one-line"
def latex(self):
new = [r"\begin{quote}", "\n"]
if self.style == "top" and ("title" in self.attributes or "author" in self.attributes):
new.extend([r"\begin{center}", '\n'])
if "title" in self.attributes:
new.extend([r"\large\textbf{", self.attributes["title"], "}\n"])
if "author" in self.attributes:
new.extend(["\n", r"\normalsize\textit{", self.attributes["author"], "}\n"])
new.extend([r"\end{center}", '\n'])
new.extend([self.convert_text(), "\n"])
if self.style == "one-line" and "author" in self.attributes \
and "title" in self.attributes:
new.extend([r"\hfill \textit{", self.attributes["author"], "} --- ",
r"\textbf{", self.attributes["title"], "}\n"])
elif self.style != "top":
if "title" in self.attributes and "author" in self.attributes:
new.extend(["\n", r"\hspace*{\fill}", r"\textbf{",
self.attributes["title"], "}", r"\linebreak"])
new.extend([r"\hspace*{\fill}", r"\textit{",
self.attributes["author"], "}\n"])
elif "author" in self.attributes:
new.extend(["\n", r"\hspace*{\fill}", r"\textit{",
self.attributes["author"], "}\n"])
elif "title" in self.attributes:
new.extend(["\n", r"\hspace*{\fill}", r"\textbf{",
self.attributes["title"], "}\n"])
new.extend([r"\end{quote}", "\n"])
return new
def html(self):
new = ['']
if self.style == "top" and "title" in self.attributes:
new.extend(['\n
',
self.attributes["title"], "
"])
if self.style == "top" and "author" in self.attributes:
new.extend(['\n
',
self.attributes["author"], "
"])
new.extend(["\n", self.convert_text()])
if self.style == "one-line" and "author" in self.attributes and\
"title" in self.attributes:
new.extend(['\n
', self.attributes["author"], " ",
" — ", self.attributes["title"], "
"])
elif self.style != "top":
if "title" in self.attributes:
new.extend(["\n", '
', self.attributes["title"], "
"])
if "author" in self.attributes:
new.extend(["\n", '
', self.attributes["author"], "
"])
new.extend(['\n
'])
return new
def other(self):
new = []
if self.style == "top" and "title" in self.attributes:
new.extend(["> __", self.attributes["title"], "__\n"])
if self.style == "top" and "author" in self.attributes:
new.extend(["> _", self.elem.attributes["author"], "_\n"])
if self.style == "top" and ("author" in self.attributes or "title" in self.attributes):
new.extend(["> \n"])
for line in self.text.split("\n"):
new.extend(["> ", line, "\n"])
if self.style == "one-line" and "author" in self.attributes and\
"title" in self.attributes:
new.extend(['>\n>_', self.attributes["author"], '_ --- __',
self.attributes["title"], '__', "\n"])
elif self.style != "top":
if "title" in self.attributes:
new.extend(['>\n >__', self.attributes["title"], '__', "\n"])
if "author" in self.attributes:
new.extend(['>\n >_', self.attributes["author"], '_', "\n"])
return new
if __name__ == "__main__":
run_transform_filter(["quote"], latex, html, other, all_formats)
PK ! |6 ( pandoc_styles/config_dir/misc/mono.theme{
"text-color": null,
"background-color": null,
"line-number-color": null,
"line-number-background-color": null,
"text-styles": {
"Annotation": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": true,
"underline": false
},
"ControlFlow": {
"text-color": null,
"background-color": null,
"bold": true,
"italic": false,
"underline": false
},
"Error": {
"text-color": null,
"background-color": null,
"bold": true,
"italic": false,
"underline": false
},
"Alert": {
"text-color": null,
"background-color": null,
"bold": true,
"italic": false,
"underline": false
},
"Preprocessor": {
"text-color": null,
"background-color": null,
"bold": true,
"italic": false,
"underline": false
},
"Information": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": true,
"underline": false
},
"Warning": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": true,
"underline": false
},
"Documentation": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": true,
"underline": false
},
"DataType": {
"text-color": null,
"background-color": null,
"bold": true,
"italic": false,
"underline": false
},
"Comment": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": true,
"underline": false
},
"CommentVar": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": true,
"underline": false
},
"Keyword": {
"text-color": null,
"background-color": null,
"bold": true,
"italic": false,
"underline": false
}
}
}
PK !
01% % 4 pandoc_styles/config_dir/postflight/delete_output.py"""
Delete the output file. Usefull, if you need the converted file only as an intermediate.
"""
from os import remove
from pandoc_styles import run_postflight_script
def postflight(self):
remove(self.file)
if __name__ == '__main__':
run_postflight_script(postflight)
PK ! p 4 pandoc_styles/config_dir/preflight/append_to_file.pyfrom pandoc_styles import run_preflight_script, file_read, file_write
def preflight(self):
text_to_append = self.cfg["append-to-file"]
if isinstance(text_to_append, list):
text_to_append = "\n".join(text_to_append)
file_write(self.files[-1], f"{file_read(self.files[-1])}\n{text_to_append}")
if __name__ == '__main__':
run_preflight_script(preflight)
PK ! u 0 pandoc_styles/config_dir/preflight/appendices.pyimport re
import yaml
from pandoc_styles import run_preflight_script, file_read, file_write
def make_appendices(self):
'''
Make appendices out of data-files and style options that render this data.
These are given in the metadata with a list called 'appendices'.
'''
if not self.cfg.get("appendices"):
return
if any(appendix.get('only-linked') for appendix in self.cfg["appendices"]):
# search for links possibly containing a link to an item in the databases
link_pattern = re.compile(r'\[.*?\]\(#(.*?)\)', re.DOTALL)
candidates = [x for f in self.files for x in link_pattern.findall(file_read(f))]
for appendix in self.cfg["appendices"]:
name = appendix["filter"]
try:
data = appendix.get("data-file", self.cfg["metadata"]["data-files"][name])
data = yaml.load_all(file_read(data))
except (FileNotFoundError, KeyError):
continue
if appendix.get('sort'):
key = appendix.get('sort', "name")
data = sorted(data, key=lambda x: x[key]) # pylint: disable=W0640
classes = appendix.get("classes", f".{name}")
appendix_heading_level = appendix.get("appendix-heading-level", 1)
header = ".hidden-heading" if appendix.get('hidden-heading') else "-"
title = appendix.get("title", name.capitalize())
entry_heading_level = self.cfg.get("appendix-entry-heading-level",
appendix_heading_level + 1)
data_text = [f'{"#" * appendix_heading_level} {title}\n']
for entry in data:
if (
(appendix.get('only-linked') and not
entry["name"].lower().replace(' ', '-') in candidates)
or
(appendix.get('entries') and not
entry["name"] in appendix['entries'])
):
continue
data_text.append(f'{"#" * entry_heading_level} {entry["name"]}'
f'{{{header} .appendix}}\n')
data_text.append(f'~~~{{{classes}}}')
data_text.append(f'{entry["name"]}\n~~~\n')
data_text = '\n'.join(data_text)
file_write(self.files[-1], f"{file_read(self.files[-1])}\n{data_text}")
if __name__ == '__main__':
run_preflight_script(make_appendices)
PK ! ?O 0 pandoc_styles/config_dir/preflight/copyrights.pyfrom pandoc_styles import run_preflight_script, file_read, file_write
def preflight(self):
copyrights = self.cfg.get("copyrights")
copyrights_header = self.cfg.get("copyrights-header", "Copyrights")
if copyrights:
copyrights = f'# {copyrights_header}{{.hidden}}\n'\
f'{copyrights}\n
\n'
file_write(self.files[-1], f"{file_read(self.files[-1])}\n{copyrights}")
if __name__ == '__main__':
run_preflight_script(preflight)
PK ! 0 pandoc_styles/config_dir/preflight/dedication.pyimport re
from pandoc_styles import run_preflight_script, file_read, file_write
def preflight(self):
dedication = self.cfg.get("dedication")
dedication_header = self.cfg.get("dedication-header", "Dedication")
if dedication:
dedication = f'# {dedication_header}{{.hidden}}\n'\
f'{dedication}\n
\n'
dedication = re.sub(r'(.?-{3}.*?(\n\.{3}\n|\n-{3}\n))',
rf"\1\n{dedication}", file_read(self.files[0]),
flags=re.DOTALL)
file_write(self.files[0], dedication)
if __name__ == '__main__':
run_preflight_script(preflight)
PK ! F.: : , pandoc_styles/config_dir/preflight/scenes.pyimport re
from pandoc_styles import run_preflight_script, file_read, file_write
def scenes(self):
style = "default"
cfg = self.cfg.get("scenes", {})
style = cfg.get("new-scene-style", "default")
def style_new_scene(_):
if self.fmt in ("latex", "pdf"):
if style == "text":
return ''.join([r"\begin{center}", cfg.get("new-scene-text", "* * *"),
r"\end{center}",
'\n', r"\noindent", "\n"])
if style == "fleuron":
return ''.join([r"\begin{center}", '\n',
r"\includegraphics[width=0.1", r"\textwidth]",
f'{{{cfg.get("new-scene-image")}}}',
"\n", r"\end{center}", '\n', r"\noindent", "\n"])
return ''.join([r"\par", "\n", r"\vspace{\baselineskip}", "\n",
r"\par", "\n\n" + r"\noindent" + "\n"])
if self.fmt in ("html", "epub", "epub3"):
if style == "text":
text = re.sub(r"([^\w])", r"\\\1", cfg.get("new-scene-text", "* * *"))
return f'\n{text}
'
if style == "fleuron":
return '\n '
return '\n
'
return "\n * * *\n"
for ffile in self.files:
text = file_read(ffile)
new_text = re.sub(r'(^\s*\*\s*\*\s*\*\s*\n)', style_new_scene, text,
flags=re.MULTILINE)
if text != new_text:
file_write(ffile, new_text)
if __name__ == '__main__':
run_preflight_script(scenes)
PK ! / * pandoc_styles/config_dir/sass/default.scss$media-breakpoint: 600px !default;
$body-max-width: 800px !default;
$base-font-size: 12pt !default;
$paragraph-line-height: "1.5" !default;
$media-font-size: 10pt !default;
$media-paragraph-line-height: "1.2" !default;
$heading-alignment: left !default;
$title-font: "Oswald", sans-serif !default;
$author-font: "Oswald", sans-serif !default;
$header-font: "Noto Sans", sans-serif !default;
$mono-font: "Fira Code", monospace !default;
$body-font: "Noto Serif", serif !default;
$indent: false !default;
$paper-box: true !default;
$footnote-highlight: "true" !default;
$footnote-highlight-color: #ffa !default;
$table-hover: "true" !default;
$table-hover-color: #ffa !default;
body {
max-width: $body-max-width;
padding-top: 2em;
font-family: $body-font;
font-size: $media-font-size;
line-height: $media-paragraph-line-height;
text-align: justify;
margin: 3em auto 0 auto;
}
.content {
margin: 1em;
padding-bottom: 2em;
}
@media only screen and (min-width: $media-breakpoint) {
body {
font-size: $base-font-size;
line-height: $paragraph-line-height;
@if $paper-box == true {
box-shadow: 1px 4px 14px #888;
}
}
.content {
margin: 1em 3em 3em 3em;
}
}
header {
text-align: center;
}
h1 {
font-family: $header-font;
margin-top: 1em;
margin-bottom: 1em;
font-size: 1.5em;
text-align: $heading-alignment;
font-weight: bold;
page-break-before: always;
text-indent: 0;
}
h2 {
font-size: 1.3em;
}
h3 {
font-size: 1.2em;
page-break-before: auto;
}
@if $indent == true {
p {
margin: 1em 0 0 0;
text-indent: 0;
}
p+p {
margin: 0;
text-indent: 1em;
}
}
@else {
p {
margin: 0;
text-indent: 0;
}
p+p {
margin-top: 1em;
}
}
a {
color: inherit;
text-decoration: underline dotted;
.footnoteRef {
vertical-align: super;
}
}
@if $footnote-highlight == "true" {
*[id^='fn']:target {
background-color: $footnote-highlight-color;
}
}
.math {
font-family: $body-font;
font-size: 0.9em;
}
blockquote {
font-style: italic;
}
table {
width: 100%;
border-spacing: 0;
th, td {
padding: 5px;
}
th {
border-bottom: 1px solid;
}
@if $table-hover == "true" {
tr:hover {
background-color: $table-hover-color;
}
}
}
.citation {
font-style: normal;
}
section.footnotes {
margin-top: 2em;
}
code {
font-family: $mono-font;
font-variant-ligatures: contextual;
font-feature-settings: "calt" 1;
font-size: 0.9em;
}
figure {
text-align: center;
margin: 1em 0;
max-width: 100%;
max-height: 100%;
page-break-inside: avoid;
clear: both;
img {
max-height: 100%;
max-width: 100%;
}
}
figcaption {
text-indent: 0;
text-align: center;
font-style: italic;
padding-left: 1em;
padding-right: 1em;
}
ol.toc {
padding: 0;
margin-left: 1em;
}
ol.toc li {
list-style-type: none;
margin: 0;
padding: 0;
}
em,
em em em,
em em em em em {
font-style: italic;
}
em em,
em em em em {
font-style: normal;
}
.DefinitionTerm{
margin: 0;
font-weight: bold;
text-indent: 0em;
}
.DefinitionDescription{
margin-left: 2em;
text-indent: 0em;
}
.date {
font-family: $author-font;
margin-top: 1em;
margin-bottom: 3em;
text-indent: 0em;
font-size: 1.2em;
text-align: center;
}
.author {
font-family: $author-font;
margin-top: 1em;
text-indent: 0em;
font-size: 1.5em;
text-align: center;
}
.main {
font-family: $title-font;
margin-top: 2em;
text-indent: 0em;
font-size: 1.6em;
font-weight: bold;
text-align: center;
}
.title {
font-family: $title-font;
text-indent: 0em;
font-size: 1.6em;
font-weight: bold;
text-align: center;
}
.subtitle {
font-family: $author-font;
margin-top: 1em;
text-indent: 0em;
font-size: 1.4em;
font-style: italic;
text-align: center;
}
PK ! :X
X
/ pandoc_styles/config_dir/sass/default_epub.scss$heading-alignment: left !default;
@page {
margin: 5pt;
}
html,
body {
margin: 0;
padding: 0;
text-align: justify;
}
code {
font-family: monospace;
}
.math {
font-size: 0.9em;
}
p {
margin: 0;
text-align: justify;
text-indent: 1.2em;
}
h1+p,
h2+p,
h3+p,
h4+p,
h5+p,
h6+p {
margin: 0;
text-align: justify;
text-indent: 0;
}
.pagebreak {
page-break-after: always;
}
a {
color: inherit;
text-decoration: none;
.footnoteRef {
vertical-align: super;
}
}
h1 {
margin-top: 1em;
margin-bottom: 2em;
font-size: 1.5em;
text-align: $heading-alignment;
font-weight: bold;
text-indent: 0;
}
h2 {
margin-top: 1em;
margin-bottom: 1.5em;
font-size: 1.3em;
text-align: $heading-alignment;
font-weight: bold;
text-indent: 0;
}
h3 {
margin-top: 1em;
margin-bottom: 1em;
font-size: 1.2em;
text-align: $heading-alignment;
font-weight: bold;
text-indent: 0;
}
.header-section-number {
display: block;
padding-bottom: 1em;
}
blockquote {
font-style: italic;
}
table {
width: 100%;
border-spacing: 0;
th, td {
padding: 5px;
}
th {
border-bottom: 1px solid;
}
}
figure {
text-align: center;
margin: 1em 0;
max-width: 100%;
max-height: 100%;
page-break-inside: avoid;
clear: both;
img {
max-height: 100%;
max-width: 100%;
}
}
figcaption {
text-indent: 0;
text-align: center;
font-style: italic;
padding-left: 1em;
padding-right: 1em;
}
.DefinitionTerm {
margin: 0;
font-weight: bold;
text-indent: 0em;
}
.DefinitionDescription {
margin-left: 2em;
text-indent: 0em;
}
.author {
margin-top: 3em;
margin-bottom: 3em;
text-indent: 0em;
font-size: 1.5em;
text-align: center;
}
.publisher {
margin-top: 3em;
margin-bottom: 3em;
text-indent: 0em;
font-size: 1.2em;
text-align: center;
}
.main {
margin-top: 2em;
text-indent: 0em;
font-size: 1.6em;
font-weight: bold;
text-align: center;
}
.title {
margin-top: 2em;
text-indent: 0em;
font-size: 1.6em;
font-weight: bold;
text-align: center;
}
.subtitle {
margin-top: 1em;
text-indent: 0em;
font-size: 1.4em;
font-style: italic;
text-align: center;
}
div#cover-image img {
max-height: 100%;
max-width: 100%;
}
ol.toc {
padding: 0;
margin-left: 1em;
li {
list-style-type: none;
margin: 0;
padding: 0;
}
}
em,
em em em,
em em em em em {
font-style: italic;
}
em em,
em em em em {
font-style: normal;
}
PK ! %8 / pandoc_styles/config_dir/sass/extra_styles.scss.NewScene {
margin-top: .75em;
margin-bottom: .75em;
text-indent: 0;
text-align: center;
+p {
text-indent: 0;
}
}
.szeneimg {
width: 10%;
vertical-align: middle;
}
.noindent {
margin: 0;
p {
text-indent: 0;
}
}
.align_left {
margin: 0;
p {
text-align: left;
}
}
.align_center {
margin: 0;
p {
text-align: center;
}
}
.align_right {
margin: 0;
p {
text-align: right;
}
}
.Poem {
margin-top: 1em;
margin-bottom: 1em;
margin-right: 1em;
margin-left: 1em;
text-align: left;
.Stanza {
page-break-inside: avoid;
}
p,
div {
text-indent: -0.5em;
margin-left: 1.5em;
margin-top: 0;
margin-bottom: 0;
}
+p {
text-indent: 0;
}
.PoemAuthor {
font-style: italic;
text-indent: 0;
text-align: right;
}
.PoemTitle {
font-weight: bold;
text-indent: 0;
text-align: right;
}
.PoemTitleTop {
font-weight: bold;
text-indent: 0;
text-align: center;
}
.PoemAuthorTop {
font-style: italic;
text-indent: 0;
text-align: center;
}
.PoemAuthorTop+p,
.PoemTitleTop+p {
padding-top: 1em;
}
.PoemTitleTop+.PoemAuthorTop {
padding-top: 0.2em;
}
.PoemSingle {
text-indent: 0;
text-align: right;
}
}
.QuoteBlock {
margin-left: 2em;
margin-right: 2em;
margin-top: 1em;
margin-bottom: 1em;
text-indent: 0;
p {
text-indent: 0;
margin-top: 0;
margin-bottom: 0;
}
p+p {
text-indent: 1.2em;
}
.QuoteAuthor {
font-style: italic;
text-indent: 0;
text-align: right;
}
.QuoteScource {
font-weight: bold;
text-indent: 0;
text-align: right;
}
.QuoteScourceTop {
font-weight: bold;
text-indent: 0;
text-align: center;
}
.QuoteAuthorTop {
font-style: italic;
text-indent: 0;
text-align: center;
}
.QuoteAuthorTop+p,
.QuoteScourceTop+p {
padding-top: 1em;
}
.QuoteScourceTop+.QuoteAuthorTop {
padding-top: 0.2em;
}
.QuoteSingle {
text-indent: 0;
text-align: right;
}
}
.Epigraph {
margin-top: 0;
margin-bottom: 1em;
margin-left: 55%;
margin-right: 1em;
text-indent: 0;
text-align: left;
p {
margin-top: 0;
margin-bottom: 0;
text-indent: 0;
}
+p {
text-indent: 0;
}
.EpigraphAuthor {
font-style: italic;
text-align: right;
border-top: thin solid;
}
}
.dedication {
color: black;
padding-top: 5em;
padding-left: 20%;
padding-right: 20%;
margin-bottom: 3em;
p {
text-indent: 0em;
text-align: center;
}
}
.copyrights {
color: black;
padding-top: 5%;
padding-left: 5%;
padding-right: 5%;
p {
font-size: 0.8em;
text-indent: 0em;
text-align: center;
}
}
.hidden {
color: transparent;
}
PK ! FAuW W - pandoc_styles/config_dir/sass/navigation.scss$nav-top: true !default;
$nav-media-breakpoint: 600px !default;
$nav-sub-nav-width: 200px;
$nav-background-color: #FFFFFF !default;
$nav-hover-background-color: #555 !default;
$nav-text-color: #000000 !default;
$nav-hover-text-color: #FFFFFF !default;
$nav-font-size: 11pt !default;
// sidebar
#navbar {
right: 1em;
top: 3em;
z-index: 1;
margin: 0;
text-align: left;
padding: 0;
position: fixed;
overflow-y: auto;
overflow-x: hidden;
max-width: 350px;
max-height: 95%;
font-size: $nav-font-size;
ul {
display: none;
width: 100%;
list-style: none;
margin: 0;
background: $nav-background-color;
li {
margin-right: 4em;
a {
display: block;
padding: 0.3em;
background: $nav-background-color;
color: #000000;
text-decoration: none;
&:hover {
color: $nav-hover-text-color;
background: $nav-hover-background-color;
}
}
}
}
input.trigger {
position: absolute;
top: -9999px;
left: -9999px;
&:checked~ul,
&:checked~ul li ul {
display: block !important;
}
}
label {
position: fixed;
right: 0.5em;
top: .2em;
width: 1.2em;
height: 1.2em;
text-align: center;
font-size: 2em;
background: $nav-background-color;
color: $nav-text-color;
&:after {
content: "\2261";
}
&:hover {
color: $nav-hover-text-color;
background: $nav-hover-background-color;
}
}
}
@if $nav-top==true {
@media only screen and (min-width: $nav-media-breakpoint) {
#navbar {
max-width: 100%;
max-height: auto;
width: 100%;
position: fixed;
top: 0;
left: 0;
overflow-y: visible;
overflow-x: visible;
background: #fff;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
ul {
display: flex;
flex-direction: row;
width: 100%;
list-style: none;
margin: 0;
margin-top: -0.5em;
background: transparent;
li {
a {
display: block;
padding: 0.5em;
background: $nav-background-color;
color: $nav-text-color;
text-decoration: none;
position: relative;
flex: 1;
}
&:hover {
color: $nav-hover-text-color;
background: $nav-hover-background-color;
} // 2nd level
ul {
padding-top: 0.5em;
margin-left: -1em;
display: none !important;
position: absolute;
top: 2.5em;
display: block;
width: $nav-sub-nav-width;
z-index: 2;
li {
position: relative;
width: 100%;
a {
padding-left: 0.5em;
color: $nav-text-color;
background: $nav-background-color;
}
ul {
z-index: 3;
top: -0.5em;
right: -$nav-sub-nav-width;
width: $nav-sub-nav-width;
li {
a {
padding-left: 0.5em;
}
}
}
}
}
&:hover>ul {
display: block !important;
}
}
}
label {
display: none;
}
}
}
}
PK ! 8c; c; $ pandoc_styles/config_dir/styles.yaml---
All:
all:
metadata:
lang: en
pdf:
command-line:
pdf-engine: xelatex
# Styles
# ----------------------------------------------------------------------------
Letter:
pdf: &pdf-letter
command-line:
template: ~/scrlttr2.tex
metadata:
paper: a4
letteroption:
- DIN
fromaddress: |
Sherlock Holmes
221B Baker Street
London
latex:
<< : *pdf-letter
Assignment:
inherits:
- Code
- Math
- Widows
- Html-self-contained-math
pdf: &pdf-assignment
metadata:
mainfont: Adobe Garamond Pro
geometry: "a4paper, twoside, top=2cm, bottom=2cm, left=2.5cm"
header-includes:
- |
\usepackage{titling}
\pretitle{\begin{center}\LARGE\textbf}
\posttitle{\par\end{center}\vskip 0.5em}
\preauthor{\begin{center}
\large \lineskip 0.5em%
\begin{tabular}[t]{c}}
\postauthor{\end{tabular}\par\end{center}}
\predate{\begin{center}\large}
\postdate{\par\end{center}}
latex:
<< : *pdf-assignment
Report:
inherits:
- Italic-quotes
- Widows
- Bibliography
- Html-self-contained
all:
command-line:
number-sections: true
toc: true
toc-depth: 3
html:
sass:
variables:
indent: true
pdf: &pdf-report
metadata:
documentclass: scrreprt
indent: true
mainfont: Calibri
sansfont: Cambria
fontsize: 12pt
geometry: "a4paper, top=2cm, bottom=2.5cm, left=2.5cm, right=4cm"
linestretch: 1.25
add-to-template:
- |
\titlehead{{$titletop-left$
\hfill $titletop-right$\\}
$titlehead$}
\publishers{\small $titlebottom$}
latex:
<< : *pdf-report
Novel:
inherits:
- Html-self-contained
- Extra-styles
pdf: &pdf-novel
command-line:
template: ~/novel.tex
top-level-division: chapter
toc: true
toc-depth: 3
metadata:
documentclass: scrbook
DIV: calc
paper: 6in:9in
BCOR: 2mm
center-headings: true
fontsize: 10pt
mainfont: Adobe Garamond Pro
sansfont: Questrial
pagestyle: plain
latex:
<< : *pdf-novel
epub:
preflight:
- ~/dedication.py
- ~/copyrights.py
sass:
files:
- ~/default_epub.scss
output-path: temp
html:
preflight:
- ~/dedication.py
- ~/copyrights.py
sass:
variables:
indent: true
# Mixins
# ----------------------------------------------------------------------------
Mobi:
epub:
postflight:
- 'path/to/kindlegen '
Default-html:
inherits: Navbar
html:
command-line:
toc: true
sass:
files:
- ~/default.scss
replace-in-template:
- pattern: \$body\$
replacement-text: |
$body$
replace-in-output:
- pattern: (<\/head>)
count: 1
add: true
replacement-text: |
epub:
sass:
files:
- ~/default_epub.scss
# special fonts are not embedded.
Html-self-contained:
inherits: Default-html
html:
command-line:
self-contained: true
sass:
output-path: temp
replace-in-template:
- pattern: \$body\$
replacement-text: |
$body$
# mathjax is not embedded.
Html-self-contained-math:
inherits: Html-self-contained
html:
replace-in-output:
- pattern:
Navbar:
html:
sass:
files:
- ~/navigation.scss
variables:
nav-top: false
nav-font-size: 11pt
nav-media-breakpoint: 600px
nav-sub-nav-width: 200px
nav-background-color: "#FFFFFF"
nav-hover-background-color: "#555"
nav-text-color: "#000000"
nav-hover-text-color: "#FFFFFF"
replace-in-template:
- pattern: \$table-of-contents\$
replacement-text: |
$table-of-contents$
Navbar-top:
inherits: Navbar
html:
sass:
variables:
nav-top: true
Extra-styles:
all:
preflight:
- ~/scenes.py
command-line:
filter:
- ~/new_page.py
- ~/epigraph.py
- ~/noindent.py
- ~/alignment.py
- ~/quote.py
- ~/poem.py
- ~/custom_styles.py
metadata:
poem-style: bottom
quote-style: bottom
scenes:
new-scene-style: default
new-scene-text: "* * *"
new-scene-image: false
html:
sass:
files:
- ~/extra_styles.scss
epub:
sass:
files:
- ~/extra_styles.scss
Widows:
pdf:
metadata:
header-includes:
- |
\widowpenalties=3 10000 10000 150
Italic-quotes:
pdf: &pdf-italic-quotes
metadata:
header-includes:
- |
\makeatletter
\g@addto@macro{\quote}{\itshape}
\makeatother
latex:
<< : *pdf-italic-quotes
Bibliography:
all:
preflight:
- ~/append_to_file.py
append-to-file:
- |
# References{.unnumbered}
command-line:
filter:
- pandoc-citeproc
pdf:
append-to-file:
- |
\setlength{\parindent}{-0.5in}
\setlength{\leftskip}{0.5in}
\setlength{\parskip}{8pt}
\noindent
Math:
html:
command-line:
mathjax: true
pdf: &pdf-math
metadata:
header-includes:
- |
\usepackage{newunicodechar}
\newunicodechar{√}{\sqrt}
latex:
<< : *pdf-math
Code:
all:
command-line:
highlight-style: tango
pdf: &pdf-code
metadata:
monofont: Fira Code
# allow code line break
add-to-template:
- |
\usepackage{fvextra}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakautoindent=true,commandchars=\\\{\}}
- |
\setmonofont[
Contextuals={Alternate}
]{$monofont$}
\makeatletter
\def\verbatim@nolig@list{}
\makeatother
latex:
<< : *pdf-code
Fancy-header:
pdf: &pdf-fancy-header
metadata:
disable-header: false
disable-footer: false
# example options: \headertitle: title, \headerauthor: author, \headerdate: date,
# \thepage: page number, \leftmark: chapter, \rightmark: section
header-left: \headertitle
header-center: false
header-right: \nouppercase\leftmark
footer-left: \headerauthor
footer-center: false
footer-right: \thepage
headrule: true
footrule: true
add-to-template:
- |
\newcommand{\headertitle}{$title$}
\newcommand{\headerauthor}{$for(author)$$author$$sep$, $endfor$}
\newcommand{\headerdate}{$date$}
\usepackage{fancyhdr}
\pagestyle{fancy}
$if(disable-header)$
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
$else$
\fancyhead{}
\lhead[$if(header-right)$$header-right$$else$$date$$endif$]{$if(header-left)$$header-left$$else$$title$$endif$}
\chead[$if(header-center)$$header-center$$else$$endif$]{$if(header-center)$$header-center$$else$$endif$}
\rhead[$if(header-left)$$header-left$$else$$title$$endif$]{$if(header-right)$$header-right$$else$$date$$endif$}
$if(headrule)$
\renewcommand{\headrulewidth}{0.4pt}
$else$
\renewcommand{\headrulewidth}{0pt}
$endif$
$endif$
$if(disable-footer)$
\renewcommand{\footrulewidth}{0pt}
$else$
\fancyfoot{}
\lfoot[$if(footer-right)$$footer-right$$else$\thepage$endif$]{$if(footer-left)$$footer-left$$else$$for(author)$$author$$sep$, $endfor$$endif$}
\cfoot[$if(footer-center)$$footer-center$$else$$endif$]{$if(footer-center)$$footer-center$$else$$endif$}
\rfoot[$if(footer-left)$$footer-left$$else$$for(author)$$author$$sep$, $endfor$$endif$]{$if(footer-right)$$footer-right$$else$\thepage$endif$}
$if(footrule)$
\renewcommand{\footrulewidth}{0.4pt}
$else$
\renewcommand{\footrulewidth}{0pt}
$endif$
$endif$
latex:
<< : *pdf-fancy-header
# report, book etc. classes for better header/footers
Renew-chaptermark:
pdf:
add-to-template:
- |
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1}{} }
Pdf-title:
pdf: &pdf-title
metadata:
header-includes:
- |
\usepackage{pagecolor}
\usepackage{afterpage}
\usepackage{xcolor}
\usepackage{setspace}
replace-in-template:
- pattern: \\maketitle
replacement-text: |
\begin{titlepage}
\newgeometry{left=6cm}
$if(titlepage-color)$
\definecolor{titlepage-color}{HTML}{$titlepage-color$}
\newpagecolor{titlepage-color}\afterpage{\restorepagecolor}
$endif$
\newcommand{\colorRule}[3][black]{\textcolor[HTML]{#1}{\rule{#2}{#3}}}
\begin{flushleft}
\noindent
\\[-1em]
\color[HTML]{$if(titlepage-text-color)$$titlepage-text-color$$else$5F5F5F$endif$}
\makebox[0pt][l]{\colorRule[$if(titlepage-rule-color)$$titlepage-rule-color$$else$435488$endif$]{1.3\textwidth}{$if(titlepage-rule-height)$$titlepage-rule-height$$else$4$endif$pt}}
\par
\noindent
{
\setstretch{1.4}
\vfill
\noindent {\huge \textbf{\textsf{$title$}}}
$if(subtitle)$
\vskip 1em
{\Large \textsf{$subtitle$}}
$endif$
\vskip 2em
\noindent
{\Large \textsf{$for(author)$$author$$sep$, $endfor$}
\vfill
}
$if(logo)$
\noindent
\includegraphics[width=$if(logo-width)$$logo-width$$else$100$endif$pt, left]{$logo$}
$endif$
\textsf{$date$}}
\end{flushleft}
\end{titlepage}
\restoregeometry
latex:
<< : *pdf-title
Listings:
pdf: &pdf-listings
command-line:
highlight-style: false
listings: true
metadata:
listings-disable-line-numbers: false
listings-frame: single
listings-text-size: small
listings-text-style: ttfamily
listing-numbers-size: tiny
listing-keyword-style: bfseries
listing-identifier-style: upshape
listing-comment-style: itshape
listings-linespread: 1.15
listing-background-color: "F7F7F7"
listing-rule-color: "B3B2B3"
listing-numbers-color: "B3B2B3"
listing-text-color: "000000"
listing-keyword-color: "435489"
listing-identifier-color: "000000"
listing-string-color: "719B6E"
listing-comment-color: "8E8E8E"
add-to-template:
- |
$if(listings)$
\usepackage{xcolor}
$if(listing-background-color)$
\definecolor{listing-background}{HTML}{$listing-background-color$}
$endif$
\definecolor{listing-rule}{HTML}{$listing-rule-color$}
\definecolor{listing-numbers}{HTML}{$listing-numbers-color$}
\definecolor{listing-text-color}{HTML}{$listing-text-color$}
\definecolor{listing-keyword}{HTML}{$listing-keyword-color$}
\definecolor{listing-identifier}{HTML}{$listing-identifier-color$}
\definecolor{listing-string}{HTML}{$listing-string-color$}
\definecolor{listing-comment}{HTML}{$listing-comment-color$}
\lstset{
$if(listings-disable-line-numbers)$
xleftmargin = 0.6em,
framexleftmargin = 0.4em,
$else$
numbers = left,
xleftmargin = 2.7em,
framexleftmargin = 2.5em,
$endif$
$if(listing-background-color)$
backgroundcolor = \color{listing-background},
$endif$
basicstyle = \color{listing-text-color}\$listings-text-size$\$listings-text-style${}\linespread{$listings-linespread$},
breaklines = true,
breakatwhitespace= true,
breakautoindent = true,
frame = $listings-frame$,
framesep = 0.6mm,
rulecolor = \color{listing-rule},
frameround = ffff,
tabsize = 4,
numberstyle = \$listing-numbers-size$\color{listing-numbers},
aboveskip = 1.0em,
belowcaptionskip = 1.0em,
keywordstyle = \color{listing-keyword}\$listing-keyword-style$,
classoffset = 0,
sensitive = true,
identifierstyle = \color{listing-identifier}\$listing-identifier-style$,
commentstyle = \color{listing-comment}\$listing-comment-style$,
stringstyle = \color{listing-string},
showstringspaces = false,
escapeinside = {/*@}{@*/}, % Allow LaTeX inside these special comments
literate =
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
{à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
{€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
{»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1
{…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1
{”}{{''}}1
}
$endif$
latex:
<< : *pdf-listings
...
PK ! Q-% % + pandoc_styles/config_dir/template/novel.tex\documentclass[$if(fontsize)$fontsize=$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(DIV)$DIV=$DIV$,$endif$$if(BCOR)$BCOR=$BCOR$,$endif$$if(papersize)$paper=$papersize$,$endif$$if(paper)$paper=$paper$,$endif$$if(parskip)$parskip=$parskip$,$endif$$if(headings)$headings=$headings$,$endif$$if(open)$open=$open$,$endif$$if(toc)$toc=$toc$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
$if(beamerarticle)$
\usepackage{beamerarticle} % needs to be loaded first
$endif$
$for(koma-options)$
\KOMAoption{$koma-options.name$}{$koma-options.arguments$}
$endfor$
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
$if(linestretch)$
\usepackage{setspace}
\setstretch{$linestretch$}
$endif$
\usepackage{verse}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
\usepackage[utf8]{inputenc}
$if(euro)$
\usepackage{eurosym}
$endif$
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
$for(fontfamilies)$
\newfontfamily\$fontfamilies.name${$fontfamilies.font$}[$fontfamilies.options$]
$endfor$
$if(euro)$
\newcommand{\euro}{€}
$endif$
$if(mainfont)$
\setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
$endif$
$if(sansfont)$
\setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
$endif$
$if(monofont)$
\setmonofont[Mapping=tex-ansi$if(monofontoptions)$,$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$endif$]{$monofont$}
$endif$
$if(mathfont)$
\setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
$endif$
$if(CJKmainfont)$
\usepackage{xeCJK}
\setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
$endif$
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\PassOptionsToPackage{backref}{hyperref}
\usepackage{bookmark}
$if(colorlinks)$
\PassOptionsToPackage{usenames,dvipsnames}{color} % color is loaded by hyperref
$endif$
\hypersetup{unicode=true,
$if(title-meta)$
pdftitle={$title-meta$},
$endif$
$if(author-meta)$
pdfauthor={$author-meta$},
$endif$
$if(keywords)$
pdfkeywords={$for(keywords)$$keywords$$sep$; $endfor$},
$endif$
$if(colorlinks)$
colorlinks=true,
linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,
citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
$else$
pdfborder={0 0 0},
$endif$
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
$if(lang)$
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
$if(babel-newcommands)$
$babel-newcommands$
$endif$
\else
\usepackage{polyglossia}
\setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
$for(polyglossia-otherlangs)$
\setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
$endfor$
\fi
$endif$
$if(natbib)$
\usepackage{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$
$if(biblatex)$
\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
$for(bibliography)$
\addbibresource{$bibliography$}
$endfor$
$endif$
$if(pagestyle)$
\pagestyle{$pagestyle$}
$endif$
\recalctypearea
$if(geometry)$
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
$if(listings)$
\usepackage{listings}
$endif$
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$if(tables)$
\usepackage{longtable,booktabs}
$endif$
$if(graphics)$
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
$endif$
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
% avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
$if(noindent)$
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
$endif$
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(number-sections)$
\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(subparagraph)$
$else$
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
$endif$
$if(dir)$
\ifxetex
% load bidi as late as possible as it modifies e.g. graphicx
$if(latex-dir-rtl)$
\usepackage[RTLdocument]{bidi}
$else$
\usepackage{bidi}
$endif$
\fi
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\TeXXeTstate=1
\newcommand{\RL}[1]{\beginR #1\endR}
\newcommand{\LR}[1]{\beginL #1\endL}
\newenvironment{RTL}{\beginR}{\endR}
\newenvironment{LTR}{\beginL}{\endL}
\fi
$endif$
% set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
$if(pdf-cover)$
\usepackage{pdfpages}
$endif$
$for(header-includes)$
$header-includes$
$endfor$
$if(subject_title)$
\subject{$subject$}
$endif$
$if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$
$if(subtitle)$
\providecommand{\subtitle}[1]{}
\subtitle{$subtitle$}
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
$if(institute)$
\providecommand{\institute}[1]{}
\institute{$for(institute)$$institute$$sep$ \and $endfor$}
$endif$
$if(date_title)$
\date{$date$}
$else$
\date{}
$endif$
$if(dedication)$
\dedication{$dedication$}
$endif$
$if(copyrights)$
\lowertitleback{\centering{$copyrights$}}
$endif$
$if(center-headings)$
\renewcommand*{\raggedsection}{\centering}
$endif$
$if(number-sections)$
$else$
\renewcommand*{\partformat}{}
\renewcommand{\chapterlinesformat}[3]{{#3}}
\renewcommand{\sectionlinesformat}[4]{\hskip #2 {#4}}
\usepackage{titletoc}
\titlecontents{part}[0em]
{\vspace{1em}\normalsize\bfseries\sffamily\relax}
{\contentslabel[\relax]{0em}}{}{\hfill\contentspage}
\titlecontents{chapter}[0em]
{\vspace{1em}\normalsize\bfseries\sffamily\relax}
{\contentslabel[\relax]{0em}}{}{\hfill\contentspage}
\titlecontents{section}[0em]
{\vspace{1em}\normalsize\bfseries\sffamily\relax}
{\contentslabel[\relax]{0em}}{}{\hfill\contentspage}
$endif$
$if(toc-dots)$
$else$
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
$endif$
\renewcommand*{\dictumauthorformat}[1]{\textit{#1}}
\renewcommand*{\figureformat}{}
\renewcommand*{\tableformat}{}
\renewcommand*{\captionformat}{}
$for(koma-fonts)$
$if(koma-fonts.element)$
\addtokomafont{$koma-fonts.element$}{$koma-fonts.fontfamily$}
$endif$
$endfor$
\begin{document}
$if(pdf-cover)$
\pagenumbering{gobble}
\includepdf{$pdf-cover$}
\clearpage{\thispagestyle{empty}\cleardoublepage}
\pagenumbering{arabic}
$endif$
$if(title)$
\maketitle
$endif$
$if(abstract)$
\begin{abstract}
$abstract$
\end{abstract}
$endif$
$for(include-before)$
$include-before$
$endfor$
$if(toc)$
{
$if(colorlinks)$
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$black$endif$}
$endif$
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
}
$endif$
$if(lot)$
\listoftables
$endif$
$if(lof)$
\listoffigures
$endif$
$body$
$if(natbib)$
$if(bibliography)$
$if(biblio-title)$
$if(book-class)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$endif$
$endif$
$if(biblatex)$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$for(include-after)$
$include-after$
$endfor$
\end{document}
PK ! %*P . pandoc_styles/config_dir/template/scrlttr2.tex\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{scrlttr2}
$if(fontfamily)$
\usepackage{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
$if(linestretch)$
\usepackage{setspace}
\setstretch{$linestretch$}
$endif$
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
$if(euro)$
\usepackage{eurosym}
$endif$
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\usepackage{xltxtra,xunicode}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{€}
$if(mainfont)$
\setmainfont{$mainfont$}
$endif$
$if(sansfont)$
\setsansfont{$sansfont$}
$endif$
$if(monofont)$
\setmonofont[Mapping=tex-ansi]{$monofont$}
$endif$
$if(mathfont)$
\setmathfont(Digits,Latin,Greek){$mathfont$}
$endif$
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
$if(geometry)$
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
$if(listings)$
\usepackage{listings}
$endif$
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
$if(tables)$
\usepackage{longtable,booktabs}
$endif$
$if(graphics)$
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
$endif$
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex]{hyperref}
\else
\usepackage[unicode=true]{hyperref}
\fi
\hypersetup{breaklinks=true,
bookmarks=true,
pdfauthor={$author-meta$},
pdftitle={$title-meta$},
colorlinks=true,
citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
pdfborder={0 0 0}}
\urlstyle{same} % don't use monospace font for urls
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
% avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
$if(numbersections)$
\setcounter{secnumdepth}{5}
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$if(lang)$
\ifxetex
\usepackage{polyglossia}
\setmainlanguage{$mainlang$}
\else
\usepackage[$lang$]{babel}
\fi
$endif$
$if(title)$
\title{$title$}
$endif$
$if(subtitle)$
\subtitle{$subtitle$}
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
$if(date)$
\date{$date$}
$endif$
$for(header-includes)$
$header-includes$
$endfor$
\newkomavar{opening}
\newkomavar{closing}
$for(letteroption)$
\LoadLetterOption{$letteroption$}
$endfor$
$if(addresseeimage)$\setkomavar{addresseeimage}{$addresseeimage$}$endif$
$if(backaddress)$\setkomavar{backaddress}{$backaddress$}\KOMAoptions{backaddress=true}$endif$
$if(customer)$\setkomavar{customer}{$customer$}$endif$
$if(date)$\setkomavar{date}{$date$}$endif$
$if(fromaddress)$\setkomavar{fromaddress}{$fromaddress$}$endif$
$if(frombank)$\setkomavar{frombank}{$frombank$}$endif$
$if(fromemail)$\setkomavar{fromemail}{$fromemail$}\KOMAoptions{fromemail=true}$else$\KOMAoptions{fromemail=false}$endif$
$if(fromfax)$\setkomavar{fromfax}{$fromfax$}\KOMAoptions{fromfax=true}$else$\KOMAoptions{fromfax=false}$endif$
$if(fromlogo)$\setkomavar{fromlogo}{$fromlogo$}\KOMAoptions{fromlogo=true}$else$\KOMAoptions{fromlogo=false}$endif$
$if(frommobilephone)$\setkomavar{frommobilephone}{$frommobilephone$}\KOMAoptions{frommobilephone=true}$else$\KOMAoptions{frommobilephone=false}$endif$
$if(fromname)$\setkomavar{fromname}{$fromname$}$endif$
$if(fromphone)$\setkomavar{fromphone}{$fromphone$}\KOMAoptions{fromphone=true}$else$\KOMAoptions{fromphone=false}$endif$
$if(fromurl)$\setkomavar{fromurl}{$fromurl$}\KOMAoptions{fromurl=true}$else$\KOMAoptions{fromurl=false}$endif$
$if(fromzipcode)$\setkomavar{fromzipcode}{$fromzipcode$}$endif$
$if(invoice)$\setkomavar{invoice}{$invoice$}$endif$
$if(location)$\setkomavar{location}{$location$}$endif$
$if(myref)$\setkomavar{myref}{$myref$}$endif$
$if(myrefname)$\setkomavar*{myref}{$myrefname$}$endif$
$if(place)$\setkomavar{place}{$place$}$endif$
$if(PPdatamatrix)$\setkomavar{PPdatamatrix}{$PPdatamatrix$}$endif$
$if(PPcode)$\setkomavar{PPcode}{$PPcode$}$endif$
$if(signature)$\setkomavar{signature}{$signature$}$endif$
$if(specialmail)$\setkomavar{specialmail}{$specialmail$}$endif$
$if(subject)$\setkomavar{subject}{$subject$}$endif$
$if(title)$\setkomavar{title}{$title$}$endif$
$if(toaddress)$\setkomavar{toaddress}{$toaddress$}\KOMAoptions{toaddress=true}$endif$
$if(toname)$\setkomavar{toname}{$toname$}\KOMAoptions{toname=true}$endif$
$if(yourmail)$\setkomavar{yourmail}{$yourmail$}$endif$
$if(yourref)$\setkomavar{yourref}{$yourref$}$endif$
$if(opening)$\setkomavar{opening}{$opening$}$endif$
$if(closing)$\setkomavar{closing}{$closing$}$endif$
\KOMAoptions{
fromalign=right
}
\begin{document}
\begin{letter}{%
$to$
}
$for(include-before)$
$include-before$
$endfor$
\opening{\usekomavar{opening}}
$body$
\closing{\usekomavar{closing}}
$if(ps)$\ps{$ps$}$endif$
$if(encl)$\encl{$encl$}$endif$
$for(include-after)$
$include-after$
$endfor$
\end{letter}
\end{document}
PK ! @&b b pandoc_styles/constants.pyfrom os.path import expanduser, join
# Generel constants
MODULE_NAME = "pandoc_styles"
CONFIG_DIR = join(expanduser("~"), MODULE_NAME)
STYLE_FILE = join(CONFIG_DIR, "styles.yaml")
PANDOC_CMD = "pandoc"
FMT = "fmt"
TO_FMT = "to_fmt"
OUTPUT_FILE = "output_file"
CFG_TEMP_FILE = "cfg.yaml"
ALL_STYLE = "All"
USER_DIR_PREFIX = "~/"
PATH_MISC = "misc"
PATH_TEMP = "temp"
PATH_SASS = "sass"
PATH_CSS = "css"
# Metadata fields constants
MD_METADATA = "metadata"
MD_CMD_LINE = "command-line"
MD_DESTINATION = "destination"
MD_OUTPUT_NAME = "output-name"
MD_FORMATS = "formats"
MD_FROM_FORMAT = "from-format"
MD_STYLE_FILE = "style-file"
MD_STYLE = "style"
MD_INHERITS = "inherits"
MD_STYLE_DEF = "style-definition"
MD_CURRENT_FILES = "current-files"
MD_TEMP_DIR = "temp-dir"
MD_CFG_DIR = "config-dir"
MD_PANDOC_STYLES_MD = "pandoc_styles_"
MD_PREFLIGHT = "preflight"
MD_POSTFLIGHT = "postflight"
MD_SASS = "sass"
MD_SASS_OUTPUT_PATH = "output-path"
MD_SASS_FILES = "files"
MD_SASS_VARS = "variables"
MD_SASS_APPEND = "append"
MD_ADD_TO_TEMPLATE = "add-to-template"
MD_REPL_IN_TEMPLATE = "replace-in-template"
MD_REPL_PATTERN = "pattern"
MD_REPL_TEXT = "replacement-text"
MD_REPL_ADD = "add"
MD_REPL_COUNT = "count"
MD_TEMPLATE = "template"
MD_REPL_IN_OUTPUT = "replace-in-output"
# Configuartion constants
CFG_FILE = "config.yaml"
CFG_PANDOC_PATH = "pandoc-path"
CFG_PYTHON_PATH = "python-path"
# Some formats:
ALL_FMTS = "all"
HTML = "html"
PDF = "pdf"
LATEX = "latex"
EPUB = "epub"
CSS = "css"
# Filter
FIL_OTHER = "other"
FIL_ALL = "all_formats"
FIL_CHECK = "check"
PK ! QmS# # pandoc_styles/filter.pyimport yaml
import panflute as pf
from panflute import ( # pylint: disable=W0611
Null, HorizontalRule, Space, SoftBreak, LineBreak, Str,
Code, BlockQuote, Note, Div, Plain, Para, Emph, Strong, Strikeout,
Superscript, Subscript, SmallCaps, Span, RawBlock, RawInline, Math,
CodeBlock, Link, Image, BulletList, OrderedList, DefinitionList,
LineBlock, Header, Quoted, Cite, Table, ListContainer,
convert_text, Element, run_filter)
from .constants import (HTML, PDF, LATEX, EPUB, MD_PANDOC_STYLES_MD,
FIL_OTHER, FIL_ALL, FIL_CHECK)
from .utils import file_read, file_write
class PandocStylesFilter():
'''
Base class for filters. Defines methods to help writing filters and to
run them.
'''
def __init__(self, func, filter_type=None, tags=None):
self._add_method(func, "func")
self.filter_type = filter_type
self.tags = tags
def run(self):
run_filter(self._pandoc_filter)
def _pandoc_filter(self, elem, doc):
self._init_filter(elem, doc)
if not self.check():
return
self.new_text = self.func() # pylint: disable=E1128
return self._return_filter()
def _init_filter(self, elem, doc):
self.elem = elem
self.doc = doc
self.cfg = dict()
self._get_format()
self.classes = elem.classes if hasattr(elem, "classes") else None
self.attributes = elem.attributes if hasattr(elem, "attributes") else None
self.text = elem.text if hasattr(elem, "text") else None
self.content = elem.content if hasattr(elem, "content") else None
def _return_filter(self):
if self.new_text is None:
return
elif self.new_text == [] or is_pandoc_element(self.new_text):
return self.new_text
return convert_text(self.new_text)
def _get_format(self):
self.fmt = self.doc.format
self.real_fmt = self.fmt
if self.fmt == PDF:
self.fmt = LATEX
elif self.fmt == EPUB:
self.fmt = HTML
def check(self):
return (not self.filter_type or isinstance(self.elem, self.filter_type)) \
and (not self.tags or any(x in self.tags for x in self.classes))
def func(self):
return
def _add_method(self, var, name):
if var is not None:
if callable(var):
setattr(self, name, var.__get__(self))
else:
raise TypeError("Only strings and functions are allowed in filter generation!")
def get_metadata(self, key, default=None):
'''Gets metadata'''
return self.doc.get_metadata(key, default)
def get_pandoc_styles_metadata(self):
'''Return the pandoc_styles cfg as a dictionary'''
try:
self.cfg = yaml.safe_load(file_read(self.get_metadata(MD_PANDOC_STYLES_MD)))
except FileNotFoundError:
self.cfg = {}
return self.cfg
def save_pandoc_styles_metadata(self):
'''Save the given cfg in the cfg-file'''
file_write(self.get_metadata(MD_PANDOC_STYLES_MD), yaml.dump(self.cfg))
def stringify(self, elem=None):
'''Stringify an element'''
if elem is None:
elem = self.elem
return stringify(elem)
def raw_block(self, *args):
'''Return a RawBlock pandoc element in self.fmt. Accepts strings, tuples
and lists as arguments.
'''
return raw(self.fmt, *args)
def raw_inline(self, *args):
'''Return a RawInline pandoc element in self.fmt. Accepts strings, tuples
and lists as arguments.
'''
return raw(self.fmt, *args, element_type=RawInline)
def run_pandoc_styles_filter(func, filter_type=None, tags=None):
"""
Run a filter with the given func. The function is now a method to a filter object
and you can access its contents through self.
"""
PandocStylesFilter(func, filter_type, tags).run()
class TransformFilter(PandocStylesFilter):
'''
Base class for filters. Defines methods to help writing filters and to
run them.
'''
# pylint: disable=W0231
def __init__(self, tags=None, latex=None, html=None, other=None,
all_formats=None, filter_type=None, check=None):
self.tags = tags or []
self.filter_type = filter_type if filter_type is not None else CodeBlock
self._add_method(latex, LATEX)
self._add_method(html, HTML)
self._add_method(other, FIL_OTHER)
self._add_method(all_formats, FIL_ALL)
self._add_method(check, FIL_CHECK)
def _pandoc_filter(self, elem, doc):
self._init_filter(elem, doc)
if not self.check():
return
self.all_formats()
self._call_filter()
return self._return_filter()
# pylint: disable=E1128
def _call_filter(self):
if self.fmt == LATEX:
self.new_text = self.latex()
elif self.fmt == HTML:
self.new_text = self.html()
else:
self.new_text = self.other()
def _return_filter(self):
if self.new_text is None:
return
elif self.new_text == [] or is_pandoc_element(self.new_text):
return self.new_text
return self.raw_block(self.new_text)
def all_formats(self):
return
def latex(self):
return None
def html(self):
return None
def other(self):
return None
def _add_method(self, var, name):
if var is not None:
if isinstance(var, str):
setattr(self, name, lambda: var.format(text=self.convert_text()))
elif callable(var):
setattr(self, name, var.__get__(self))
else:
raise TypeError("Only strings and functions are allowed in filter generation!")
def convert_text(self, text=None, input_fmt='markdown', extra_args=None):
'''Converts text in input_fmt to self.fmt'''
if text is None:
text = self.text
return convert_text(text, input_fmt, self.fmt, False, extra_args)
def run_transform_filter(tags=None, latex=None, html=None, other=None,
all_formats=None, filter_type=None, check=None):
'''
Creates and runs a pandoc filter.
tags: The default check method checks, if these tags are in the classes of
the element the filter searches for. If it is [], check only checks for
the element type
latex, html, other: Accepts either a function or a string.
> Function: These functions are registered as a method and are executed,
if the format of the output matches the name. These methods have to
either return a string/list of strings or an pandoc element/list of elements.
> String: The string is returned as the output. The string can contain
the formating {text], which gets replaced by the converted text
of the element.
all_formats: This method is executed before the format specific methods
and is used to execute shared code.
filter_type: If the filter searches for an element other than a CodeBlock
check: Replace the default check method with your own.
'''
pandoc_filter = TransformFilter(tags, latex, html, other, all_formats, filter_type,
check)
pandoc_filter.run()
def is_pandoc_element(ele):
if isinstance(ele, Element):
return True
elif isinstance(ele, (list, tuple)):
return is_pandoc_element(ele[0])
return False
def raw(fmt, *args, element_type=RawBlock):
'''Return a Raw pandoc element in the given format. Accepts strings,
lists and tuples as arguments.
'''
text = []
for s in args:
if isinstance(s, str):
text.append(s)
elif isinstance(s, list):
text.extend(s)
elif isinstance(s, tuple):
text.extend(list(s))
else:
raise TypeError('Only strings and lists/tuples of strings are allowed in raw')
if fmt not in ['tex', 'latex', 'html', 'context']:
return convert_text(''.join(text))
return element_type(''.join(text), fmt)
def stringify(elem, newlines=True):
"""
Return the raw text version of an element (and its children elements).
Example:
>>> e1 = Emph(Str('Hello'), Space, Str('world!'))
>>> e2 = Strong(Str('Bye!'))
>>> para = Para(e1, Space, e2)
>>> stringify(para)
'Hello world! Bye!\n\n'
:param newlines: add a new line after a paragraph (default True)
"""
if isinstance(elem, ListContainer):
elem = Para(*elem)
return pf.stringify(elem, newlines)
def strip_html_tag(text, tag="p"):
text = text.replace(f"<{tag}>", "")
return text.replace(f"{tag}>", "")
PK ! w w pandoc_styles/flight_scripts.pyfrom argparse import ArgumentParser
import yaml
from .constants import CFG_TEMP_FILE, MD_TEMP_DIR, MD_CURRENT_FILES, FMT, OUTPUT_FILE
from .utils import file_read, file_write
class FlightScript:
def __init__(self, func, flight_type):
setattr(self, "fligh_script", func.__get__(self))
parser = ArgumentParser(description="")
parser.add_argument('--cfg', nargs='?', default="",
help='The cfg from pandoc_styles')
args = parser.parse_args()
self.cfg = yaml.safe_load(file_read(args.cfg))
self.fmt = self.cfg[FMT]
if flight_type == "preflight":
self.files = self.cfg[MD_CURRENT_FILES]
else:
self.file = self.cfg[OUTPUT_FILE]
def fligh_script(self):
pass
def save_cfg(self):
file_write(CFG_TEMP_FILE, yaml.dump(self.cfg), self.cfg.get(MD_TEMP_DIR))
def run_preflight_script(func):
script = FlightScript(func, "preflight")
script.fligh_script()
def run_postflight_script(func):
script = FlightScript(func, "postflight")
script.fligh_script()
PK ! ~# pandoc_styles/format_mappings.pyFORMAT_TO_EXTENSION = {
"asciidoc": "adoc",
"adoc": "adoc",
"beamer": "beamer",
"commonmark": "md",
"context": "ctx",
"ctx": "ctx",
"docbook": "dbk",
"docbook4": "dbk",
"docbook5": "dbk",
"dbk": "dbk",
"docx": "docx",
"dzslides": "html",
"epub": "epub",
"epub2": "epub",
"epub3": "epub",
"fb2": "fb2",
"gfm": "md",
"haddock": "html",
"html": "html",
"html4": "html",
"html5": "html",
"icml": "icml",
"jats": "jats",
"json": "json",
"latex": "latex",
"man": "man",
"markdown": "md",
"markdown_github": "md",
"markdown_mmd": "md",
"markdown_phpextra": "md",
"markdown_strict": "md",
"markdown+lhs": "lhs",
"lhs": "lhs",
"md": "md",
"mediawiki": "html",
"ms": "ms",
"muse": "muse",
"odt": "odt",
"opendocument": "odt",
"opml": "opml",
"org": "org",
"pdf": "pdf",
"plain": "txt",
"pptx": "pptx",
"revealjs": "html",
"rst": "rst",
"rtf": "rtf",
"s5": "s5",
"slideous": "html",
"slidy": "html",
"tei": "tei",
"texinfo": "texi",
"textile": "tex",
"zimwiki": "html",
}
PK ! p0