]> pere.pagekite.me Git - text-mekanikerord.git/commitdiff
Bytt til dblatex for å bygge PDF.
authorPetter Reinholdtsen <pere@hungry.com>
Fri, 14 Aug 2020 16:02:50 +0000 (18:02 +0200)
committerPetter Reinholdtsen <pere@hungry.com>
Fri, 14 Aug 2020 16:02:50 +0000 (18:02 +0200)
Makefile [new file with mode: 0644]
book.xml [new file with mode: 0644]
dedication.xml [new file with mode: 0644]
images/cc.png [new file with mode: 0644]
images/cc.svg [new file with mode: 0644]
make-glossary
myindexstyle.ist [new file with mode: 0644]
pdf.xsl [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..5421581
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,23 @@
+all: book.pdf
+
+clean:
+       $(RM) *~
+
+distclean: clean
+
+XMLLINTOPTS = --nonet --noout  --xinclude --postvalid
+lint: book.xml glossary.xml
+       xmllint $(XMLLINTOPTS) book.xml
+
+glossary.xml: make-glossary meksme-utf8.xml
+       ./make-glossary > glossary.rst
+
+DBLATEX_OPTS = \
+       -T simple \
+       -b xetex \
+       --indexstyle=myindexstyle.ist \
+       -V \
+       -P latex.index.tool=xindy \
+       -p pdf.xsl
+book.pdf: book.xml glossary.xml
+       dblatex $(DBLATEX_OPTS) book.xml
diff --git a/book.xml b/book.xml
new file mode 100644 (file)
index 0000000..61c0131
--- /dev/null
+++ b/book.xml
@@ -0,0 +1,95 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" >
+<book id="index" lang="nb">
+<bookinfo>
+ <title>Mekanikerordbok</title>
+
+ <abbrev>norsk/engelsk/nordsamisk/svensk/finsk</abbrev>
+
+ <subtitle></subtitle>
+
+ <pubdate>2020-08-14</pubdate>
+
+ <edition>1</edition>
+
+ <releaseinfo>testutgave</releaseinfo>
+
+ <authorgroup>
+  <author>
+   <firstname>Petter</firstname>
+   <surname>Reinholdtsen</surname>
+  </author>
+ </authorgroup>
+
+ <subjectset scheme="libraryofcongress">
+   <subject>
+     <subjectterm>Intellectual property&mdash;United States.</subjectterm>
+   </subject>
+   <subject>
+     <subjectterm>Mass media&mdash;United States.</subjectterm>
+   </subject>
+   <subject>
+     <subjectterm>Technological innovations&mdash;United States.</subjectterm>
+   </subject>
+   <subject>
+     <subjectterm>Art&mdash;United States.</subjectterm>
+   </subject>
+ </subjectset>
+
+
+ <publisher>
+   <publishername>Petter Reinholdtsen</publishername>
+   <address><city>Oslo</city></address>
+ </publisher>
+
+ <copyright>
+   <year>2020</year>
+   <holder>Petter Reinholdtsen</holder>
+ </copyright>
+ <legalnotice>
+   <para>
+     <inlinemediaobject>
+       <imageobject>
+        <imagedata fileref="images/cc.png" contentdepth="3em" width="100%" align="center"/>
+       </imageobject>
+       <imageobject>
+        <imagedata fileref="images/cc.svg" contentdepth="3em" width="100%" align="center"/>
+       </imageobject>
+       <textobject>
+        <phrase>Creative Commons, Some rights reserved</phrase>
+       </textobject>
+     </inlinemediaobject>
+   </para>
+
+   <para>
+Denne boken er lisensieret under en Creative Commons Navngivelse 4.0
+Internasjonal lisens.  For mer informasjon om lisensen, besøk
+<ulink url="http://creativecommons.org/licenses/by/4.0/"/>.
+   </para>
+ </legalnotice>
+
+ <abstract>
+  <title>Flerspråklig mekanikerordbok</title>
+  <para>
+    Ordbok for mekanikere med informasjon på norsk, nordsamisk,
+    svensk, finsk og engelsk.
+  </para>
+ </abstract>
+
+ <biblioid class="isbn">978-82-?</biblioid>
+
+<!-- LCCN from
+     http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?v3=1&DB=local&CMD=010a+2003063276&CNT=10+records+per+page
+     -->
+  <biblioid class="libraryofcongress">?</biblioid>
+
+  <biblioid class="uri">http://example.com/</biblioid>
+
+</bookinfo>
+
+<xi:include href="dedication.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+<xi:include href="glossary.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</book>
diff --git a/dedication.xml b/dedication.xml
new file mode 100644 (file)
index 0000000..148b8ea
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<dedication>
+</dedication>
diff --git a/images/cc.png b/images/cc.png
new file mode 100644 (file)
index 0000000..58eb423
Binary files /dev/null and b/images/cc.png differ
diff --git a/images/cc.svg b/images/cc.svg
new file mode 100644 (file)
index 0000000..71b3ad8
--- /dev/null
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   version="1.1"
+   width="88.022011"
+   height="31.022003"
+   id="svg2"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="cc.svg">
+  <metadata
+     id="metadata29">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs27" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="699"
+     inkscape:window-height="480"
+     id="namedview25"
+     showgrid="false"
+     fit-margin-top="0"
+     fit-margin-left="0"
+     fit-margin-right="0"
+     fit-margin-bottom="0"
+     inkscape:zoom="3.7045455"
+     inkscape:cx="44.011012"
+     inkscape:cy="15.511004"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0"
+     inkscape:current-layer="svg2" />
+  <radialGradient
+     id="SVGID_1_"
+     cx="1156.1123"
+     cy="1087.813"
+     r="181.64529"
+     gradientTransform="matrix(0.2613,0,0,0.2613,-258.11089,-273.3578)"
+     gradientUnits="userSpaceOnUse">
+    <stop
+       offset="0"
+       stop-color="#F5F7F5"
+       id="stop5" />
+    <stop
+       offset="1"
+       stop-color="#A5B2AC"
+       id="stop7" />
+  </radialGradient>
+  <path
+     stroke-miterlimit="3.8637"
+     d="m 87.522012,4.374 c 0,-2.14 -1.771,-3.874 -3.955,-3.874 l -79.1089997,0 c -2.184,0 -3.95599999,1.734 -3.95499999,3.874 l -0.003,25.522 c 0.092,0.21 0.188,0.418 0.283,0.626 L 87.239012,30.521 c 0.095,-0.208 0.19,-0.415 0.282,-0.625 l 0,-25.522 z"
+     id="path9"
+     inkscape:connector-curvature="0"
+     style="fill:url(#SVGID_1_);fill-opacity:0.62999998;stroke:#000000;stroke-miterlimit:3.86369991" />
+  <polygon
+     points="0.479,30.521 0.479,20.957 87.521,20.957 87.521,30.521 "
+     id="polygon11"
+     transform="translate(0.01101231,0.011)" />
+  <path
+     d="m 1.2375155,28.137438 c 0,1.23682 0.8843263,1.672799 2.0345689,1.672799 0.49782,0 1.3388576,-0.07112 1.7470082,-0.726632 0.2380879,-0.383414 0.2380879,-0.788473 0.2380879,-1.443987 0,-0.590582 0,-0.819393 -0.1978912,-1.153335 C 4.9046868,26.217275 4.6233102,25.957543 4.363578,25.768928 L 3.0339965,24.866049 C 2.7433438,24.67125 2.6072936,24.5352 2.6072936,23.922974 c 0,-0.590582 0.2597322,-0.726632 0.6215021,-0.726632 0.5905815,0 0.5905815,0.39269 0.5905815,0.748276 l 0,0.528741 1.3388577,0 0,-0.726632 c 0,-1.255372 -1.0791255,-1.576946 -1.8706903,-1.576946 -0.7080794,0 -1.2058995,0.207168 -1.4749078,0.435979 -0.4792678,0.395783 -0.5287406,0.946168 -0.5287406,1.518197 0,0.748276 0.185523,1.255372 0.8719581,1.722272 l 1.2893849,0.862682 c 0.3524937,0.238088 0.4576234,0.457623 0.4576234,0.977088 0,0.655514 0,1.091493 -0.6647908,1.091493 -0.6555146,0 -0.6555146,-0.426703 -0.6555146,-0.850313 l 0,-0.853406 -1.3512258,0 0,1.063665 z M 9.867427,24.009551 c 0,-0.704987 -0.126774,-1.091494 -0.4885439,-1.391422 -0.3432175,-0.281377 -0.8626819,-0.457624 -1.5274727,-0.457624 -0.8317614,0 -1.3821463,0.259732 -1.6604308,0.562753 -0.3741381,0.395783 -0.3834142,0.943076 -0.3834142,1.255373 l 0,4.10315 c 0,0.933799 0.4050585,1.722272 2.0562132,1.722272 0.4885439,0 1.174979,-0.06184 1.6109581,-0.519465 0.2906527,-0.290652 0.3957824,-0.66479 0.3957824,-1.205899 l 0,-4.069138 -0.00309,0 z m -1.363594,3.877431 c 0,0.352494 0,0.862682 -0.6647908,0.862682 -0.6647907,0 -0.6864351,-0.476176 -0.6864351,-0.893603 l 0,-3.698091 c 0,-0.405059 0,-0.96472 0.6957113,-0.96472 0.6555146,0 0.6555146,0.528741 0.6555146,0.915247 l 0,3.778485 0,0 z m 1.982004,1.76556 1.329582,0 -0.102038,-6.357254 1.202807,6.357254 1.267741,0 1.184255,-6.357254 -0.126774,6.357254 1.34195,0 0,-7.334342 -2.170619,0 -0.862682,5.132803 -0.871959,-5.132803 -2.192263,0 0,7.334342 z m 6.858167,0 3.645527,0 0,-1.13169 -2.294301,0 0,-2.254104 2.065489,0 0,-1.110046 -2.065489,0 0,-1.725364 2.201539,0 0,-1.122414 -3.552765,0 0,7.343618 z m 6.307782,0 1.348134,0 0,-3.231192 0.646238,0 c 0.704988,0 0.704988,0.352494 0.704988,0.853406 l 0,1.567669 c 0,0.219536 0.04329,0.531833 0.197891,0.810117 l 1.484184,0 c -0.281377,-0.228811 -0.312297,-0.612226 -0.312297,-0.986364 l 0,-1.496552 c 0,-0.986364 -0.674067,-1.184255 -0.998732,-1.26774 0.655514,-0.142235 0.946167,-0.309205 0.946167,-1.246096 l 0,-0.788473 c 0,-0.674067 0,-1.558393 -1.320305,-1.558393 l -2.69936,0 0,7.343618 0.0031,0 z m 1.348134,-6.283045 0.708079,0 c 0.299929,0 0.621502,0 0.621502,0.60295 l 0,0.695711 c 0,0.374138 -0.0093,0.704987 -0.621502,0.704987 l -0.708079,0 0,-2.003648 z m 3.688815,-1.051297 1.338858,0 0,7.334342 -1.338858,0 0,-7.334342 z m 5.998577,2.36851 0,-1.069849 c 0,-0.457624 -0.13605,-0.853406 -0.550385,-1.122414 -0.435979,-0.281377 -1.069849,-0.333942 -1.40379,-0.333942 -2.025293,0 -2.090226,1.23682 -2.090226,1.972728 l 0,4.174268 c 0,1.215175 0.936891,1.496552 1.589314,1.496552 0.779196,0 1.100769,-0.374138 1.298661,-0.590582 l 0,0.435979 1.153334,0 0,-3.979468 -2.192263,0 0,1.10077 0.841037,0 0,1.144058 c 0,0.352494 0,0.850314 -0.674066,0.850314 -0.476176,0 -0.643147,-0.250456 -0.643147,-0.735908 l 0,-3.865062 c 0,-0.395783 0,-0.946168 0.686435,-0.946168 0.633871,0 0.633871,0.405059 0.633871,0.769921 l 0,0.695711 1.351225,0 0,0.0031 z m 0.807025,4.965832 1.348134,0 0,-3.354874 1.23682,0 0,3.354874 1.348134,0 0,-7.334342 -1.348134,0 0,2.887974 -1.23682,0 0,-2.887974 -1.348134,0 0,7.334342 z m 4.267029,-6.273769 1.348134,0 0,6.273769 1.360502,0 0,-6.273769 1.351226,0 0,-1.060573 -4.059862,0 0,1.060573 z m 4.279398,4.758665 c 0,1.23682 0.881234,1.672799 2.034569,1.672799 0.49782,0 1.338857,-0.07112 1.743916,-0.726632 0.24118,-0.383414 0.24118,-0.788473 0.24118,-1.443987 0,-0.590582 0,-0.819393 -0.197892,-1.153335 -0.157694,-0.269008 -0.435979,-0.52874 -0.698803,-0.717355 L 45.834153,24.866049 C 45.5435,24.67125 45.40745,24.5352 45.40745,23.922974 c 0,-0.590582 0.259732,-0.726632 0.621502,-0.726632 0.590581,0 0.590581,0.39269 0.590581,0.748276 l 0,0.528741 1.338858,0 0,-0.726632 c 0,-1.255372 -1.079125,-1.576946 -1.867598,-1.576946 -0.70808,0 -1.2059,0.207168 -1.474908,0.435979 -0.479268,0.395783 -0.531833,0.946168 -0.531833,1.518197 0,0.748276 0.188615,1.255372 0.87505,1.722272 l 1.286293,0.862682 c 0.352494,0.238088 0.457624,0.457623 0.457624,0.977088 0,0.655514 0,1.091493 -0.664791,1.091493 -0.655515,0 -0.655515,-0.426703 -0.655515,-0.850314 l 0,-0.853405 -1.351226,0 0.0093,1.063665 0,0 z m 6.851982,1.515104 1.351226,0 0,-3.231192 0.643147,0 c 0.708079,0 0.708079,0.352494 0.708079,0.853406 l 0,1.567669 c 0,0.219536 0.0402,0.531833 0.197891,0.810117 l 1.487276,0 c -0.281376,-0.228811 -0.312297,-0.612226 -0.312297,-0.986364 l 0,-1.496552 c 0,-0.986364 -0.677159,-1.184255 -0.998732,-1.26774 0.655515,-0.142235 0.946167,-0.309205 0.946167,-1.246096 l 0,-0.788473 c 0,-0.674067 0,-1.558393 -1.320305,-1.558393 l -2.702452,0 0,7.343618 z m 1.351226,-6.283045 0.704988,0 c 0.299929,0 0.621502,0 0.621502,0.60295 l 0,0.695711 c 0,0.374138 -0.0093,0.704987 -0.621502,0.704987 l -0.704988,0 0,-2.003648 z m 3.580594,6.283045 3.645527,0 0,-1.13169 -2.297393,0 0,-2.254104 2.068581,0 0,-1.110046 -2.068581,0 0,-1.725364 2.204632,0 0,-1.122414 -3.552766,0 0,7.343618 z m 4.270121,-1.515104 c 0,1.23682 0.884327,1.672799 2.037661,1.672799 0.49782,0 1.338858,-0.07112 1.743916,-0.726632 0.238088,-0.383414 0.238088,-0.788473 0.238088,-1.443987 0,-0.590582 0,-0.819393 -0.197891,-1.153335 -0.154602,-0.269008 -0.435979,-0.52874 -0.695711,-0.717355 L 61.891168,24.866049 C 61.600516,24.67125 61.464465,24.5352 61.464465,23.922974 c 0,-0.590582 0.259733,-0.726632 0.621502,-0.726632 0.590582,0 0.590582,0.39269 0.590582,0.748276 l 0,0.528741 1.34195,0 0,-0.726632 c 0,-1.255372 -1.082218,-1.576946 -1.870691,-1.576946 -0.704987,0 -1.205899,0.207168 -1.474907,0.435979 -0.476176,0.395783 -0.528741,0.946168 -0.528741,1.518197 0,0.748276 0.185523,1.255372 0.871958,1.722272 l 1.289385,0.862682 c 0.352494,0.238088 0.457623,0.457623 0.457623,0.977088 0,0.655514 0,1.091493 -0.66479,1.091493 -0.655515,0 -0.655515,-0.426703 -0.655515,-0.850314 l 0,-0.853405 -1.351226,0 0,1.063665 0.0031,0 z m 4.835966,1.515104 3.645527,0 0,-1.13169 -2.297393,0 0,-2.254104 2.068582,0 0,-1.110046 -2.068582,0 0,-1.725364 2.20154,0 0,-1.122414 -3.552766,0 0,7.343618 z m 4.353607,0 1.351226,0 0,-3.231192 0.643146,0 c 0.70808,0 0.70808,0.352494 0.70808,0.853406 l 0,1.567669 c 0,0.219536 0.0402,0.531833 0.194799,0.810117 l 1.487276,0 C 73.38741,29.423731 73.35649,29.040316 73.35649,28.666178 l 0,-1.496552 c 0,-0.986364 -0.677159,-1.184255 -0.99564,-1.26774 0.655514,-0.142235 0.943075,-0.309205 0.943075,-1.246096 l 0,-0.788473 c 0,-0.674067 0,-1.558393 -1.317213,-1.558393 l -2.702452,0 0,7.343618 0,0 z m 1.351226,-6.283045 0.704987,0 c 0.299929,0 0.621502,0 0.621502,0.60295 l 0,0.695711 c 0,0.374138 -0.01237,0.704987 -0.621502,0.704987 l -0.704987,0 0,-2.003648 z m 4.526761,6.283045 1.360502,0 1.382146,-7.334342 -1.382146,0 -0.664791,4.851426 -0.717355,-4.851426 -1.434712,0 1.456356,7.334342 z m 3.240468,0 3.645527,0 0,-1.13169 -2.297393,0 0,-2.254104 2.068582,0 0,-1.110046 -2.068582,0 0,-1.725364 2.20154,0 0,-1.122414 -3.552766,0 0,7.343618 z m 4.353607,0 2.170619,0 c 1.703719,0 1.858322,-0.955443 1.858322,-1.972728 l 0,-3.429083 c 0,-0.581305 -0.04947,-1.079125 -0.435979,-1.474908 C 85.904029,22.3182 85.372196,22.3182 84.936217,22.3182 l -2.179895,0 0,7.334342 z m 1.348133,-6.264493 0.528741,0 c 0.590582,0 0.810117,0.09276 0.810117,0.748276 l 0,3.654803 c 0,0.269009 0,0.698804 -0.488544,0.769921 -0.114406,0.02164 -0.216443,0.02164 -0.850314,0.02164 l 0,-5.194644 z"
+     id="path13"
+     inkscape:connector-curvature="0"
+     style="fill:#ffffff" />
+  <g
+     transform="matrix(3.13012,0,0,3.13012,-108.74099,-119.879)"
+     id="g15">
+    <circle
+       cx="48.800999"
+       cy="41.818001"
+       id="ellipse17"
+       r="2.3139999"
+       style="fill:#ffffff" />
+    <path
+       d="m 48.797,39.188 c -0.721,0 -1.356,0.267 -1.847,0.764 -0.505,0.511 -0.779,1.174 -0.779,1.866 0,0.699 0.267,1.347 0.772,1.851 0.505,0.504 1.162,0.778 1.854,0.778 0.692,0 1.363,-0.273 1.883,-0.785 0.49,-0.483 0.75,-1.124 0.75,-1.844 0,-0.713 -0.26,-1.361 -0.758,-1.859 -0.504,-0.504 -1.153,-0.771 -1.875,-0.771 z m 0.007,0.476 c 0.592,0 1.118,0.223 1.529,0.634 0.404,0.403 0.621,0.936 0.621,1.52 0,0.591 -0.21,1.109 -0.613,1.506 -0.425,0.418 -0.974,0.641 -1.537,0.641 -0.57,0 -1.104,-0.223 -1.515,-0.634 -0.411,-0.411 -0.642,-0.951 -0.642,-1.513 0,-0.569 0.231,-1.109 0.642,-1.527 0.404,-0.411 0.924,-0.627 1.515,-0.627 z"
+       id="path19"
+       inkscape:connector-curvature="0" />
+    <path
+       d="m 48.771,41.381 c -0.149,-0.271 -0.403,-0.379 -0.697,-0.379 -0.429,0 -0.77,0.303 -0.77,0.815 0,0.522 0.321,0.816 0.784,0.816 0.298,0 0.551,-0.163 0.691,-0.411 l -0.326,-0.166 c -0.073,0.175 -0.184,0.227 -0.324,0.227 -0.242,0 -0.353,-0.201 -0.353,-0.466 0,-0.265 0.093,-0.466 0.353,-0.466 0.07,0 0.21,0.038 0.291,0.213 l 0.351,-0.183 z"
+       id="path21"
+       inkscape:connector-curvature="0" />
+    <path
+       d="m 50.289,41.381 c -0.149,-0.271 -0.402,-0.379 -0.697,-0.379 -0.429,0 -0.77,0.303 -0.77,0.815 0,0.522 0.321,0.816 0.784,0.816 0.298,0 0.551,-0.163 0.691,-0.411 L 49.97,42.056 c -0.073,0.175 -0.184,0.227 -0.324,0.227 -0.242,0 -0.353,-0.201 -0.353,-0.466 0,-0.265 0.094,-0.466 0.353,-0.466 0.071,0 0.21,0.038 0.292,0.213 l 0.351,-0.183 z"
+       id="path23"
+       inkscape:connector-curvature="0" />
+  </g>
+</svg>
index 6095a008377e50145794ad51c9f3d06b70486a27..9e8f89fb067f53bc86cc914e46341b7c9041ead7 100755 (executable)
@@ -3,7 +3,9 @@
 from lxml import etree
 from lxml.etree import tostring
 
 from lxml import etree
 from lxml.etree import tostring
 
-tree = etree.parse('mekanikk-1999/meksme-utf8.xml')
+filemakerxml = 'meksme-utf8.xml'
+
+tree = etree.parse(filemakerxml)
 root = tree.getroot()
 
 #print(root)
 root = tree.getroot()
 
 #print(root)
@@ -11,7 +13,6 @@ root = tree.getroot()
 
 cols = (
     'topic', 'sme', 'desc-sme', 'desc-nb', 'nb', 'sv', 'fi', 'en', 'is',
 
 cols = (
     'topic', 'sme', 'desc-sme', 'desc-nb', 'nb', 'sv', 'fi', 'en', 'is',
-    'unknown',
 )
 
 resultset = root.find("{http://www.filemaker.com/fmpxmlresult}RESULTSET")
 )
 
 resultset = root.find("{http://www.filemaker.com/fmpxmlresult}RESULTSET")
@@ -29,36 +30,67 @@ for row in resultset.getchildren():
         index += 1
     #print(d)
     words.append(d)
         index += 1
     #print(d)
     words.append(d)
+def langsort(lang, e):
+    if lang in e:
+        return e[lang]
+    else:
+        return e['sme']
 
 
-def make_glossary(lang):
-    print(".. glossary::")
-    print()
+def make_glossary_docbook(lang):
+    import lxml.builder
+    E = lxml.builder.ElementMaker(
+        nsmap={
+#            'xi': "http://www.w3.org/2001/XInclude",
+        }
+    )
+
+    langcodes = ('en', 'nb', 'sme', 'sv', 'fi',)
 
 
-    def langsort(e):
-        if lang in e:
-            return e[lang]
-        else:
-            return e['sme']
-    for e in sorted(words, key=langsort):
+    def indexit(entry, wlist, lang=None):
+        for w in wlist.split(","):
+            if "" != w:
+                if lang:
+                    w += "[%s]" % lang
+                entry.append(E.indexterm(E.primary(w)))
+    glossary = E.glosslist()
+    for e in sorted(words, key=lambda x: langsort(lang, x)):
+        if 'topic' not in e:
+            e['topic'] = 'n/a'
         if lang in e and 'desc-%s' % lang in e:
         if lang in e and 'desc-%s' % lang in e:
-            if 'topic' not in e:
-                e['topic'] = 'n/a'
-            #print(e)
-            print("  %s [%s]\n     %s" % (e[lang], e['topic'], e['desc-%s' % lang]))
-            print()
-        else:
-            # ERROR / missing definition
-            pass
+            entry = E.glossentry(
+                E.glossterm('%s [%s]' % (e[lang], e['topic'])),
+            )
+            indexit(entry, e[lang])
+            lstr = ""
+            for l in langcodes:
+                if l != lang and l in e:
+                    lstr += "%s (%s) " % (e[l], l)
+                    # Add foreign words to index, split on comma
+                    indexit(entry, e[l], l)
+            entry.append(E.glossdef(E.para(e['desc-%s' % lang])))
+            if "" != lstr:
+                entry.append(E.glossdef(E.para(lstr)))
+            glossary.append(entry)
 
 
-print("Nordsamisk")
-print("==========")
-print()
-make_glossary(lang='sme')
+    content = lxml.etree.tostring(glossary,
+                                  pretty_print=True,
+                                  xml_declaration=True,
+                                  encoding='UTF-8')
+#    print(content)
+    with open('glossary.xml', 'wb') as f:
+        f.write(content)
 
 
-print("Norsk")
-print("=====")
-print()
-make_glossary(lang='nb')
+def make_glossary(lang):
+    make_glossary_docbook(lang)
+
+if True:
+    print("Norsk/bokmål")
+    print()
+    make_glossary(lang='nb')
+else:
+    print("Nordsamisk")
+    print()
+    make_glossary(lang='sme')
 
 #print("Engelsk")
 #print("=====")
 
 #print("Engelsk")
 #print("=====")
diff --git a/myindexstyle.ist b/myindexstyle.ist
new file mode 100644 (file)
index 0000000..229c845
--- /dev/null
@@ -0,0 +1,34 @@
+%%
+%% This is file `myindexstyle.ist', from <URL: http://bugs.debian.org/685721 >
+%%
+%% The idea is from Ingo Kloeckl, Latex2e:
+%% Herbert Voss 000726
+%%
+%% This is a MAKEINDEX style file which should be used to generate the
+%% formatted change history for use with the doc package. The TeX
+%% commands used below are defined in doc.sty.  The commands for
+%% MAKEINDEX like `level' `item_x1' are described in `` Makeindex, A
+%% General Purpose, Formatter-Independent Index Processor'' by Pehong
+%% Chen.
+%%
+headings_flag       1          % headings yes
+heading_prefix   "\\textbf{"   % boldfont
+heading_suffix   "}\n"         % newline
+symhead_positive "Symbols"
+%% preamble
+%%   "\\begin{theindex}\n"
+%% item_1
+%%   "\\par\\leavevmode\\hangindent10pt\\makebox[10pt][l]{--}"
+%% item_01
+%%   "\\par\\leavevmode\\hangindent10pt\\makebox[10pt][l]{--}"
+%% item_x1
+%%   "\\par\\leavevmode\\hangindent10pt\\makebox[10pt][l]{--}"
+%% item_2
+%%   "\\par\\leavevmode\\hangindent20pt\\makebox[20pt][l]{-- -- }"
+%% item_12
+%%   "\\par\\leavevmode\\hangindent20pt\\makebox[20pt][l]{-- -- }"
+%% item_x2
+%%   "\\par\\leavevmode\\hangindent20pt\\makebox[20pt][l]{-- -- }"
+%%
+%%
+%% End of file `myindexstyle.ist'.
diff --git a/pdf.xsl b/pdf.xsl
new file mode 100644 (file)
index 0000000..c24de00
--- /dev/null
+++ b/pdf.xsl
@@ -0,0 +1,12 @@
+<?xml version='1.0' encoding="iso-8859-1"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
+
+  <!-- xsl:param name="paper.type">a4</xsl:param -->
+  <xsl:param name="double.sided">1</xsl:param>
+  <xsl:param name="page.margin.inner">0.8in</xsl:param>
+  <xsl:param name="page.margin.outer">0.55in</xsl:param>
+  <xsl:param name="page.margin.top">0.55in</xsl:param>
+  <xsl:param name="page.margin.bottom">0.55in</xsl:param>
+  <xsl:param name="latex.class.options">a4paper,openright,twoside</xsl:param>
+
+</xsl:stylesheet>