{"id":4720,"date":"2016-02-11T12:37:15","date_gmt":"2016-02-11T11:37:15","guid":{"rendered":"https:\/\/www.bdjl.de\/localhost\/?p=4720"},"modified":"2016-02-11T13:13:23","modified_gmt":"2016-02-11T12:13:23","slug":"writer2dokuwiki","status":"publish","type":"post","link":"https:\/\/www.bdjl.de\/localhost\/?p=4720","title":{"rendered":"Writer2DokuWiki"},"content":{"rendered":"<p>Bisher nutzte ich f\u00fcr die Konvertierung von Texten f\u00fcr DokuWiki das Plugin <a href=\"http:\/\/www.ooowiki.de\/Writer2DokuWiki.html\" target=\"_blank\">Writer2Dokuwiki<\/a> und hatte wenig Probleme. Das jetzt frisch verf\u00fcgbare LibreOffce 5.1 schmiert mir hierbei jedoch kommentarlos ab, so dass ich auf die Schnelle eine andere M\u00f6glichkeit brauchte. Diese ist nun eine Kombination aus tidy und pandoc.<\/p>\n<p><a href=\"https:\/\/www.bdjl.de\/localhost\/wp-content\/uploads\/2016\/02\/loexportformat.png\" rel=\"attachment wp-att-4721\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-4721\" src=\"https:\/\/www.bdjl.de\/localhost\/wp-content\/uploads\/2016\/02\/loexportformat-640x439.png\" alt=\"loexportformat\" width=\"640\" height=\"439\" srcset=\"https:\/\/www.bdjl.de\/localhost\/wp-content\/uploads\/2016\/02\/loexportformat-640x439.png 640w, https:\/\/www.bdjl.de\/localhost\/wp-content\/uploads\/2016\/02\/loexportformat-768x527.png 768w, https:\/\/www.bdjl.de\/localhost\/wp-content\/uploads\/2016\/02\/loexportformat-624x428.png 624w, https:\/\/www.bdjl.de\/localhost\/wp-content\/uploads\/2016\/02\/loexportformat.png 810w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>In LibreOffice wird das Exportformat f\u00fcr HTML Dateien zuerst unter \/Extras \/Optionen \/Laden-Speichern \/HTML-Kompatibilit\u00e4t auf UTF-8 umgeschaltet.<\/p>\n<p>\u00dcber \/Datei \/Speichern unter wird nun das HTML-Format ausgew\u00e4hlt und die Datei gespeichert.<\/p>\n<p>Hinweis: Der Exportdialog unter \/Datei \/Exportieren&#8230; erzeugt XHTML Dateien, die noch schwerer zu putzen sind. Also nutze ich diese Funktion nicht.<\/p>\n<p>Der von LibreOffice erzeugte HTML-Code ist grauenhaft. Also muss dieser mit tidy geputzt werden. Die tidy.conf liegt hierbei in meinem Stammordner im dortigen ~\/bin Verzeichnis:<\/p>\n<pre class=\"lang:default decode:true \"># \/home\/dirk\/bin\/tidy.conf\r\n\r\nclean: yes\r\ndrop-proprietary-attributes: yes\r\ndrop-empty-paras: yes\r\noutput-html: yes\r\ninput-encoding: utf8\r\noutput-encoding: utf8\r\njoin-classes: yes\r\njoin-styles: yes\r\nshow-body-only: yes\r\nforce-output: yes<\/pre>\n<p>Ein<\/p>\n<pre class=\"lang:default decode:true\">tidy -q -config \/home\/dirk\/bin\/tidy.conf -i inputdatei.html | sed 's\/ class=\"c[0-9]*\"\/\/g' &gt; geputzt.html<\/pre>\n<p>wirfft weg, was wir nicht brauchen. Ein bischen class=western kann dabei \u00fcbrig bleiben, tut aber nicht weiter weh.<\/p>\n<p>Als n\u00e4chstes kommt pandoc in einer Version gr\u00f6\u00dfer gleich 1.13 zum Einsatz (unter Ubuntu 15.10 vorhanden):<\/p>\n<pre class=\"lang:default decode:true \">pandoc -s -r html geputzt.html -t dokuwiki &gt; fuerdokuwiki.txt<\/pre>\n<p>Die TXT Datei dann mit einem Editor \u00f6ffnen und den Inhalt in DokuWiki einf\u00fcgen. Voila. Zusammen macht das dann<\/p>\n<pre class=\"lang:default decode:true\">tidy -q -config \/home\/dirk\/bin\/tidy.conf -i inputdatei.html | sed 's\/ class=\"c[0-9]*\"\/\/g' | pandoc -s -r html -t dokuwiki &gt; dokuwiki.txt ; kate dokuwiki.txt<\/pre>\n<p>oder gleich als Skript verpackt:<\/p>\n<pre class=\"lang:default decode:true\">#!\/bin\/bash\r\ntidy -q -config \/home\/dirk\/bin\/tidy.conf -i $1 | sed 's\/ class=\"c[0-9]*\"\/\/g' | pandoc -s -r html -t dokuwiki | leafpad<\/pre>\n<p>Das klappte hier mit less und leafpad, das von mir sonst bevorzugte kate wollte nicht von stdin lesen. Da muss ich noch einmal nachsehen, woran das lag.<\/p>\n<p>Man kann auch den Aufruf von LibreOffice und damit den ersten Schritt in das Skript integrieren, sofern die (angelieferten) Dokumente mit Formatvorlagen erstellt wurden. Das ist in meinem Kollegium hoffnungslos &#8211; aber im Prinzip ginge ein<\/p>\n<pre class=\"lang:default decode:true\">soffice --headless --convert-to html:HTML datei.doc<\/pre>\n<p>Quellen: [<a href=\"https:\/\/www.dokuwiki.org\/tips:htmltowiki\" target=\"_blank\">1<\/a>] [<a href=\"http:\/\/tidy.sourceforge.net\/docs\/quickref.html\" target=\"_blank\">2<\/a>]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bisher nutzte ich f\u00fcr die Konvertierung von Texten f\u00fcr DokuWiki das Plugin Writer2Dokuwiki und hatte wenig Probleme. Das jetzt frisch verf\u00fcgbare LibreOffce 5.1 schmiert mir hierbei jedoch kommentarlos ab, so dass ich auf die Schnelle eine andere M\u00f6glichkeit brauchte. Diese ist nun eine Kombination aus tidy und pandoc. In LibreOffice wird das Exportformat f\u00fcr HTML [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,10],"tags":[467,101,543,544],"class_list":["post-4720","post","type-post","status-publish","format-standard","hentry","category-office","category-schule","tag-dokuwiki-2","tag-libreoffice","tag-pandoc","tag-tidy"],"_links":{"self":[{"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=\/wp\/v2\/posts\/4720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4720"}],"version-history":[{"count":9,"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=\/wp\/v2\/posts\/4720\/revisions"}],"predecessor-version":[{"id":4730,"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=\/wp\/v2\/posts\/4720\/revisions\/4730"}],"wp:attachment":[{"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bdjl.de\/localhost\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}