summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlotte Koch <charlotte@magentastripe.com>2023-09-19 12:44:36 -0700
committerCharlotte Koch <charlotte@magentastripe.com>2023-09-19 12:44:36 -0700
commit02808570709fd7684e0e943a046625fde7e2fe42 (patch)
tree548b183fcb4871fb405d419205c637593922e8a5
parent2f777c7f46ade1b3d0b59e7bc6a1da6bb71580e0 (diff)
Initial Asciidoc -> docx converter
It is missing the "reference document" such that the resultant docx has the expected styling -- that will be next.
-rw-r--r--mk/willora.mk19
1 files changed, 19 insertions, 0 deletions
diff --git a/mk/willora.mk b/mk/willora.mk
index d434b82..ee091dc 100644
--- a/mk/willora.mk
+++ b/mk/willora.mk
@@ -10,6 +10,7 @@ PAPERBACK_OUT?= ${NAME}-paperback.pdf
HARDCOVER_OUT?= ${NAME}-hardcover.pdf
EPUB_OUT?= ${NAME}.epub
DOCBOOK_OUT?= ${NAME}.xml
+DOCX_OUT?= ${NAME}.docx
PAPERBACK_ADOC_TOTAL= ${PAPERBACK_OUT}.adoc
HARDCOVER_ADOC_TOTAL= ${HARDCOVER_OUT}.adoc
EPUB_ADOC_TOTAL= ${EPUB_OUT}.adoc
@@ -17,6 +18,7 @@ DOCBOOK_ADOC_TOTAL= ${DOCBOOK_OUT}.adoc
BUNDLE?= bundle
RUBY?= ruby
+PANDOC?= pandoc
THEME?= poppy
THEMEDIR?= ${WILLORABASE}/themes
FONTDIR?= ${WILLORABASE}/fonts
@@ -58,6 +60,9 @@ epub: ${EPUB_OUT}
.PHONY: docbook
docbook: ${DOCBOOK_OUT}
+.PHONY: docx
+docx: ${DOCX_OUT}
+
########## ########## ##########
# ===== PAPERBACK =====
@@ -201,6 +206,20 @@ ${DOCBOOK_ADOC_TOTAL}: ${CHAPTERS} ${UNICODE_TABLE}
########## ########## ##########
+# ===== DOCX =====
+
+# Thematic breaks are 'visible' in the Docbook source but they are ignored
+# in the conversion to docx. So we have to make them look the way we want
+# ("# # #") right now.
+CLEANFILES+= ${DOCX_OUT}
+${DOCX_OUT}: ${DOCBOOK_OUT}
+ sed -E -e 's,<\?asciidoc-hr\?>,\&\#35; \&\#35; \&\#35;,' ${DOCBOOK_OUT} | \
+ ${PANDOC} --from docbook --to docx \
+ -o ${.TARGET} \
+ -
+
+########## ########## ##########
+
# ===== COMMON =====
CLEANFILES+= ${DEDICATION_OUT}