Add basic TOC file
This commit is contained in:
parent
e450824d9b
commit
b2715d4a23
2 changed files with 67 additions and 0 deletions
61
md_pdf/assets/templates/toc.xsl
Normal file
61
md_pdf/assets/templates/toc.xsl
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xsl:stylesheet version="2.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:outline="http://wkhtmltopdf.org/outline"
|
||||||
|
xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
|
||||||
|
indent="yes" />
|
||||||
|
<xsl:template match="outline:outline">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Table of Contents</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<style>
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 20px;
|
||||||
|
font-family: arial;
|
||||||
|
}
|
||||||
|
div {border-bottom: 1px dashed rgb(200,200,200);}
|
||||||
|
span {float: right;}
|
||||||
|
li {list-style: none;}
|
||||||
|
ul {
|
||||||
|
font-size: 20px;
|
||||||
|
font-family: arial;
|
||||||
|
}
|
||||||
|
ul ul {font-size: 80%; }
|
||||||
|
ul {padding-left: 0em;}
|
||||||
|
ul ul {padding-left: 1em;}
|
||||||
|
a {text-decoration:none; color: black;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Table of Contents</h1>
|
||||||
|
<ul><xsl:apply-templates select="outline:item/outline:item"/></ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="outline:item">
|
||||||
|
<li>
|
||||||
|
<xsl:if test="@title!=''">
|
||||||
|
<div>
|
||||||
|
<a>
|
||||||
|
<xsl:if test="@link">
|
||||||
|
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="@backLink">
|
||||||
|
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:value-of select="@title" />
|
||||||
|
</a>
|
||||||
|
<span> <xsl:value-of select="@page" /> </span>
|
||||||
|
</div>
|
||||||
|
</xsl:if>
|
||||||
|
<ul>
|
||||||
|
<xsl:comment>added to prevent self-closing tags in QtXmlPatterns</xsl:comment>
|
||||||
|
<xsl:apply-templates select="outline:item"/>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
|
@ -14,6 +14,12 @@ DEFAULT_MARGIN_HORIZONTAL = '2.5cm'
|
||||||
STYLE_FILE = os.path.join(STATIC_DIR, 'style.css')
|
STYLE_FILE = os.path.join(STATIC_DIR, 'style.css')
|
||||||
HEADER_FILE = os.path.join(TEMPLATES_DIR, 'header.html')
|
HEADER_FILE = os.path.join(TEMPLATES_DIR, 'header.html')
|
||||||
FOOTER_FILE = os.path.join(TEMPLATES_DIR, 'footer.html')
|
FOOTER_FILE = os.path.join(TEMPLATES_DIR, 'footer.html')
|
||||||
|
TOC_TEMPLATE_FILE = os.path.join(TEMPLATES_DIR, 'toc.xsl')
|
||||||
|
|
||||||
|
TOC_OPTIONS = {
|
||||||
|
'xsl-style-sheet': TOC_TEMPLATE_FILE
|
||||||
|
}
|
||||||
|
|
||||||
PDF_OPTIONS = {
|
PDF_OPTIONS = {
|
||||||
"no-pdf-compression": "",
|
"no-pdf-compression": "",
|
||||||
"enable-internal-links": "",
|
"enable-internal-links": "",
|
||||||
|
|
Reference in a new issue