add PDF output (using LibreOffice) v_0 v0.4
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed, 25 Sep 2019 23:59:20 +0200
branchv_0
changeset 36 9e5c3383ba50
parent 35 db3eb602fa60
child 37 04190261ad54
add PDF output (using LibreOffice)
Makefile
templates/ssm.odt.xsl
--- a/Makefile	Wed Sep 25 12:38:48 2019 +0200
+++ b/Makefile	Wed Sep 25 23:59:20 2019 +0200
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-all: validate xhtml txt
+all: validate xhtml txt pdf logo-png statistics
 
 validate:
 	xmllint --noout --schema schema/ssm.xsd text/ssm.en.xml
@@ -24,6 +24,11 @@
 	cp templates/*.css build
 	cp templates/*.woff build
 
+pdf:
+	mkdir -p build
+	xsltproc --output build/ssm.en.fodt --nonet templates/ssm.odt.xsl text/ssm.en.xml
+	libreoffice --convert-to pdf --outdir build build/ssm.en.fodt
+
 # TODO: better line wrapping
 txt:
 	mkdir -p build
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/ssm.odt.xsl	Wed Sep 25 23:59:20 2019 +0200
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	Sane Software Manifesto helper tools
+	Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, version 3.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<xsl:stylesheet 
+	version="1.0"
+	xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
+	xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
+	xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
+	xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
+	xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
+	xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
+	xmlns:m="tag:globalcode.info,2019:sane-software/manifesto"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:fn="http://www.w3.org/2005/xpath-functions"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="tag:globalcode.info,2019:sane-software/manifesto ssm.xsd"
+	exclude-result-prefixes="fn m xs xsi">
+	
+	<xsl:output 
+		method="xml" 
+		indent="yes" 
+		encoding="UTF-8"/>
+		
+	<xsl:template match="/m:manifesto">
+		<office:document office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+			<xsl:call-template name="styles"/>
+			<office:body>
+				<office:text>
+					<text:p text:style-name="Title">
+						<xsl:value-of select="m:title"/>
+					</text:p>
+					<!-- TODO: remove hardcoded warning, use version from mercurial -->
+					<text:p text:style-name="Subtitle">&lt;DRAFT&gt; Please note that this is a draft version. Stay tuned for v1.0.0! &lt;/DRAFT&gt;</text:p>
+					<text:p text:style-name="Paragraph">
+						<xsl:value-of select="m:preamble"/>
+					</text:p>
+					<xsl:apply-templates select="m:chapter"/>
+				</office:text>
+			</office:body>
+		</office:document>
+	</xsl:template>
+	
+	
+	<xsl:template match="m:chapter">
+		<text:h text:style-name="Heading_1" text:outline-level="1">
+			<xsl:value-of select="m:name"/>
+		</text:h>
+		<text:list text:style-name="List_1">
+			<xsl:apply-templates select="m:item"/>
+		</text:list>
+	</xsl:template>
+	
+	
+	<xsl:template match="m:item">
+		<text:list-item>
+			<text:p>
+				<xsl:apply-templates select="m:text"/>
+			</text:p>
+			
+			<xsl:if test="m:item">
+				<text:list text:style-name="List_1">
+					<xsl:apply-templates select="m:item"/>
+				</text:list>
+			</xsl:if>
+			
+		</text:list-item>
+	</xsl:template>
+	
+	<xsl:template match="m:text">
+		<xsl:apply-templates/>
+		<xsl:text>&#10;</xsl:text>
+	</xsl:template>
+	
+	<xsl:template name="styles">
+		<office:font-face-decls>
+			<style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol" style:font-charset="x-symbol"/>
+			<style:font-face style:name="Sawasdee" svg:font-family="Sawasdee" style:font-adornments="Tučné" style:font-pitch="variable"/>
+			<style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/>
+			<style:font-face style:name="Lohit Devanagari" svg:font-family="&apos;Lohit Devanagari&apos;" style:font-family-generic="system" style:font-pitch="variable"/>
+			<style:font-face style:name="Noto Sans CJK SC" svg:font-family="&apos;Noto Sans CJK SC&apos;" style:font-family-generic="system" style:font-pitch="variable"/>
+		</office:font-face-decls>
+	
+		<office:styles>
+			<style:default-style style:family="paragraph">
+				<style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
+				<style:text-properties style:use-window-font-color="true" style:font-name="Liberation Sans" fo:font-size="12pt" fo:language="cs" fo:country="CZ" style:letter-kerning="true" style:font-name-asian="Noto Sans CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+			</style:default-style>
+			<style:style style:name="Standard" style:family="paragraph" style:class="text">
+				<style:paragraph-properties fo:text-align="justify" style:justify-single-word="false"/>
+				<style:text-properties style:font-size-asian="10.5pt"/>
+			</style:style>
+			<style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Paragraph" style:class="text">
+				<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" loext:contextual-spacing="false" fo:keep-with-next="always"/>
+				<style:text-properties style:font-name="Liberation Sans" fo:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable" fo:font-size="14pt" style:font-name-asian="Noto Sans CJK SC" style:font-family-asian="&apos;Noto Sans CJK SC&apos;" style:font-family-generic-asian="system" style:font-pitch-asian="variable" style:font-size-asian="14pt" style:font-name-complex="Lohit Devanagari" style:font-family-complex="&apos;Lohit Devanagari&apos;" style:font-family-generic-complex="system" style:font-pitch-complex="variable" style:font-size-complex="14pt"/>
+			</style:style>
+			<style:style style:name="Paragraph" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+				<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.247cm" loext:contextual-spacing="false" fo:line-height="115%"/>
+				<style:text-properties style:font-name="Liberation Sans" fo:font-family="&apos;Liberation Sans&apos;" style:font-style-name="Běžné" style:font-family-generic="swiss" style:font-pitch="variable" style:font-size-asian="10.5pt"/>
+			</style:style>
+			<style:style style:name="Title" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Paragraph" style:class="chapter">
+				<style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+				<style:text-properties style:font-name="Sawasdee" fo:font-family="Sawasdee" style:font-style-name="Tučné" style:font-pitch="variable" fo:font-size="28pt" fo:font-weight="bold" style:font-size-asian="28pt" style:font-weight-asian="bold" style:font-size-complex="28pt" style:font-weight-complex="bold"/>
+			</style:style>
+			<style:style style:name="Subtitle" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Paragraph" style:class="chapter">
+				<style:paragraph-properties fo:margin-top="0.106cm" fo:margin-bottom="0.212cm" loext:contextual-spacing="false" fo:text-align="center" style:justify-single-word="false"/>
+				<style:text-properties fo:font-size="10pt" style:font-size-asian="18pt" style:font-size-complex="18pt"/>
+			</style:style>
+			<style:style style:name="Heading_1" style:display-name="Heading 1" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Paragraph" style:default-outline-level="1" style:class="text">
+				<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" loext:contextual-spacing="false"/>
+				<style:text-properties style:font-name="Sawasdee" fo:font-family="Sawasdee" style:font-style-name="Tučné" style:font-pitch="variable" fo:font-size="130%" fo:font-weight="bold" style:font-size-asian="130%" style:font-weight-asian="bold" style:font-size-complex="130%" style:font-weight-complex="bold"/>
+			</style:style>
+			<style:style style:name="Footer" style:family="paragraph" style:parent-style-name="Standard" style:class="extra">
+				<style:paragraph-properties text:number-lines="false" text:line-number="0">
+					<style:tab-stops>
+						<style:tab-stop style:position="8.5cm" style:type="center"/>
+						<style:tab-stop style:position="17cm" style:type="right"/>
+					</style:tab-stops>
+				</style:paragraph-properties>
+				<style:text-properties fo:font-size="6pt"/>
+			</style:style>
+		
+			<style:style style:name="Numbering_20_Symbols" style:display-name="Numbering Symbols" style:family="text"/>
+			<text:list-style style:name="List_1" style:display-name="List 1">
+				<text:list-level-style-bullet text:level="1" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+					<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+						<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.4cm" fo:text-indent="-0.4cm" fo:margin-left="0.4cm"/>
+					</style:list-level-properties>
+					<style:text-properties style:font-name="OpenSymbol"/>
+				</text:list-level-style-bullet>
+				<text:list-level-style-bullet text:level="2" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+					<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+						<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.801cm" fo:text-indent="-0.4cm" fo:margin-left="0.801cm"/>
+					</style:list-level-properties>
+					<style:text-properties style:font-name="OpenSymbol"/>
+				</text:list-level-style-bullet>
+				<text:list-level-style-bullet text:level="3" text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+					<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
+						<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.199cm" fo:text-indent="-0.4cm" fo:margin-left="1.199cm"/>
+					</style:list-level-properties>
+					<style:text-properties style:font-name="OpenSymbol"/>
+				</text:list-level-style-bullet>
+			</text:list-style>
+		
+			<text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/>
+			<text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/>
+		
+		</office:styles>
+	
+		<office:automatic-styles>
+			<style:page-layout style:name="pm1">
+				<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm">
+					<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+				</style:page-layout-properties>
+				<style:header-style/>
+				<style:footer-style>
+					<style:header-footer-properties fo:min-height="0cm" fo:margin-top="0.2cm"/>
+				</style:footer-style>
+			</style:page-layout>
+		</office:automatic-styles>
+	
+		<office:master-styles>
+			<style:master-page style:name="Standard" style:page-layout-name="pm1">
+				<style:footer>
+					<!-- TODO: move license information to XML file -->
+					<text:p text:style-name="Footer">Sane Software Manifesto &lt;https://sane-software.globalcode.info/&gt; Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) CC-BY-ND<text:tab/>
+						<text:page-number text:select-page="current">1</text:page-number> / <text:page-count>1</text:page-count>
+					</text:p>
+				</style:footer>
+			</style:master-page>
+		</office:master-styles>
+	</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file