Ich habe eine HTML mit den figure
, img
und figcaption
-Tags, und ich möchte sie in ein Microsoft Word-Dokument umgewandelt bekommen.von HTML <figure> und <figcaption> zu Microsoft Word
Das Bild, das von img
verwiesen wird, sollte in das Word-Dokument eingefügt werden und das figcaption
sollte in seine Beschriftung konvertiert werden (wobei auch die Bildnummer beibehalten wird).
Ich habe versucht, die HTML mit Word 2013 zu öffnen, aber die figcaption
wird nicht als die Bildunterschrift konvertiert, aber es ist nur ein einfacher Text unter dem Bild.
Gibt es ein Mindestarbeitsmuster, um es zu erledigen? Ich habe einen Blick auf https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats#Word_XML_Format_example, aber es ist zu verbose, nur ein Hallo Welt Probe zu greifen.
figure .image {
width: 100%;
}
figure {
text-align: center;
display: table;
max-width: 30%; /* demo; set some amount (px or %) if you can */
margin: 10px auto; /* not needed unless you want centered */
}
article {
counter-reset: figures;
}
figure {
counter-increment: figures;
}
figcaption:before {
content: "Fig. " counter(figures) " - "; /* For I18n support; use data-counter-string. */
}
<figure>
<p><img class="image" src="https://upload.wikimedia.org/wikipedia/commons/c/ca/Matterhorn002.jpg"></p>
<figcaption>Il monte Cervino.</figcaption>
</figure>
<figure>
<p><img class="image" src="https://upload.wikimedia.org/wikipedia/commons/2/26/Banner_clouds.jpg"></p>
<figcaption>La nuvola che spesso è vicino alla vetta.</figcaption>
</figure>
Ich habe versucht, mit pandoc auf Windows
pandoc -f html -t docx -o hello.docx hello.html
aber ohne Glück, wie Sie das sehen und "Fig. 2" fehlt "Abb. 1":
Mein Pando c:
c:\temp>.\pandoc.exe -v
pandoc.exe 1.19.2.1
Compiled with pandoc-types 1.17.0.4, texmath 0.9, skylighting 0.1.1.4
Default user data directory: C:\Users\ale\AppData\Roaming\pandoc
Copyright (C) 2006-2016 John MacFarlane
Web: http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
Edit 1
Es ist in Ordnung, auch einige C# verwenden, um es getan. Vielleicht kann ich den HTML-Code mithilfe eines C# -Programms in ein XML-Word-Format umwandeln.
haben Sie die neueste Version pandoc versucht? – mb21
@ mb21 Ich habe es mit Pandus 1.19.2.1 getestet, was ich denke, ist das Neueste. –
das ist seltsam, ich habe gerade versucht, auf Linux und es lädt die Bilder und bettet sie in die Word-Datei (mit libreoffice geöffnet). also vielleicht ein Windows-Ding ... – mb21