From: Petter Reinholdtsen Date: Fri, 14 Aug 2020 16:02:50 +0000 (+0200) Subject: Bytt til dblatex for å bygge PDF. X-Git-Tag: published-en-nb-2021-07-17~90 X-Git-Url: https://pere.pagekite.me/gitweb/text-mekanikerord.git/commitdiff_plain/09b0cc579c82da1af73d7f27113c6d3c73a7ae3a Bytt til dblatex for å bygge PDF. --- diff --git a/Makefile b/Makefile new file mode 100644 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 index 0000000..61c0131 --- /dev/null +++ b/book.xml @@ -0,0 +1,95 @@ + + + + + Mekanikerordbok + + norsk/engelsk/nordsamisk/svensk/finsk + + + + 2020-08-14 + + 1 + + testutgave + + + + Petter + Reinholdtsen + + + + + + Intellectual property—United States. + + + Mass media—United States. + + + Technological innovations—United States. + + + Art—United States. + + + + + + Petter Reinholdtsen +
Oslo
+
+ + + 2020 + Petter Reinholdtsen + + + + + + + + + + + + Creative Commons, Some rights reserved + + + + + +Denne boken er lisensieret under en Creative Commons Navngivelse 4.0 +Internasjonal lisens. For mer informasjon om lisensen, besøk +. + + + + + Flerspråklig mekanikerordbok + + Ordbok for mekanikere med informasjon på norsk, nordsamisk, + svensk, finsk og engelsk. + + + + 978-82-? + + + ? + + http://example.com/ + +
+ + + + + +
diff --git a/dedication.xml b/dedication.xml new file mode 100644 index 0000000..148b8ea --- /dev/null +++ b/dedication.xml @@ -0,0 +1,3 @@ + + + diff --git a/images/cc.png b/images/cc.png new file mode 100644 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 index 0000000..71b3ad8 --- /dev/null +++ b/images/cc.svg @@ -0,0 +1,107 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/make-glossary b/make-glossary index 6095a00..9e8f89f 100755 --- a/make-glossary +++ b/make-glossary @@ -3,7 +3,9 @@ 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) @@ -11,7 +13,6 @@ root = tree.getroot() cols = ( 'topic', 'sme', 'desc-sme', 'desc-nb', 'nb', 'sv', 'fi', 'en', 'is', - 'unknown', ) 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) +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 '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("=====") diff --git a/myindexstyle.ist b/myindexstyle.ist new file mode 100644 index 0000000..229c845 --- /dev/null +++ b/myindexstyle.ist @@ -0,0 +1,34 @@ +%% +%% This is file `myindexstyle.ist', from +%% +%% 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 index 0000000..c24de00 --- /dev/null +++ b/pdf.xsl @@ -0,0 +1,12 @@ + + + + + 1 + 0.8in + 0.55in + 0.55in + 0.55in + a4paper,openright,twoside + +