summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlotte Koch <dressupgeekout@gmail.com>2023-06-04 16:29:28 -0700
committerCharlotte Koch <dressupgeekout@gmail.com>2023-06-04 18:38:25 -0700
commit9405ee50ef1b1e9684e5e017e7ccb11fbb223af6 (patch)
tree3192ad42b5f1749a6f72b8aa811274f606bea000
parent534780257ddc4d2928d0262c5165a25efcf259bc (diff)
Preliminary support for EPUB3 output
The real change is that now there are 2 different ADOC_TOTALs, one for PDF and one for EPUB. This is because the workarounds currently in place for frontmatter styling don't work in EPUB output (because an EPUB can't "include" a PDF). At the moment, both of the ADOC_TOTALs are identical and the frontmatter bug is still present in EPUB output, but at least the plumbing is in place to make them different.
-rw-r--r--Gemfile2
-rw-r--r--mk/willora.mk59
2 files changed, 56 insertions, 5 deletions
diff --git a/Gemfile b/Gemfile
index a988aa0..5604218 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,5 @@
source "https://rubygems.org"
gem "asciidoctor-pdf", git: "https://github.com/dressupgeekout/asciidoctor-pdf", branch: "2.3.4-charlotte"
+gem "asciidoctor-epub3", git: "https://github.com/dressupgeekout/asciidoctor-epub3", branch: "charlotte"
+gem "epubcheck-ruby"
gem "rghost"
diff --git a/mk/willora.mk b/mk/willora.mk
index 12e8b9a..8606431 100644
--- a/mk/willora.mk
+++ b/mk/willora.mk
@@ -7,13 +7,16 @@ WILLORABASE?= ${.CURDIR}
NAME?= mybook
PDF_OUT?= ${NAME}.pdf
-ADOC_TOTAL= ${NAME}.adoc
+PDF_ADOC_TOTAL= ${PDF_OUT}.adoc
+EPUB_OUT?= ${NAME}.epub
+EPUB_ADOC_TOTAL=${EPUB_OUT}.adoc
BUNDLE?= bundle
THEME?= poppy
THEMEDIR?= ${WILLORABASE}/themes
FONTDIR?= ${WILLORABASE}/fonts
MEDIA?= prepress
+PUBLISHER?= WilloraPDF
COLOPHON_OUT?= colophon.pdf
DEDICATION_OUT?= dedication.pdf
@@ -23,13 +26,18 @@ CUSTOM_PDF_CONVERTER= ${WILLORABASE}/lib/willora_pdf_converter.rb
########## ########## ##########
+.PHONY: all
+all: ${PDF_OUT} ${EPUB_OUT}
+
+########## ########## ##########
+
# XXX: Figure out why I can't do this:
# 'asciidoctor-pdf -a optimize'
# > GPL Ghostscript 9.50: Can't find initialization file gs_init.ps.
# https://docs.asciidoctor.org/pdf-converter/latest/optimize-pdf/
CLEANFILES+= ${PDF_OUT}
-${PDF_OUT}: ${THEMEDIR}/${THEME}-theme.yml ${CUSTOM_PDF_CONVERTER} ${ADOC_TOTAL} Gemfile.lock ${COLOPHON_OUT} ${DEDICATION_OUT} ${ACKNOWLEDGMENTS_OUT}
+${PDF_OUT}: ${THEMEDIR}/${THEME}-theme.yml ${CUSTOM_PDF_CONVERTER} ${PDF_ADOC_TOTAL} Gemfile.lock ${COLOPHON_OUT} ${DEDICATION_OUT} ${ACKNOWLEDGMENTS_OUT}
${BUNDLE} exec asciidoctor-pdf \
-v \
-r ${CUSTOM_PDF_CONVERTER} \
@@ -40,10 +48,10 @@ ${PDF_OUT}: ${THEMEDIR}/${THEME}-theme.yml ${CUSTOM_PDF_CONVERTER} ${ADOC_TOTAL}
-a pdf-themesdir=${THEMEDIR} \
-a media=${MEDIA} \
-a text-align=justify \
- ${ADOC_TOTAL}
+ ${PDF_ADOC_TOTAL}
-CLEANFILES+= ${ADOC_TOTAL}
-${ADOC_TOTAL}: ${CHAPTERS}
+CLEANFILES+= ${PDF_ADOC_TOTAL}
+${PDF_ADOC_TOTAL}: ${CHAPTERS}
rm -f ${.TARGET}
.for chapter in ${CHAPTERS}
dos2unix < ${chapter} | sed -E \
@@ -93,6 +101,47 @@ ${ACKNOWLEDGMENTS_OUT}: ${THEMEDIR}/${THEME}-acknowledgments-theme.yml ${ACKNOWL
-a media=print \
${ACKNOWLEDGMENTS_FILE}
+########## ########## ##########
+
+# XXX: '-a ebook-validate' doesn't work because:
+# > RUBYOPT=-d epubcheck
+# Exception `LoadError' at /usr/pkg/lib/ruby/3.0.0/rubygems.rb:1339 - cannot
+# load such file -- rubygems/defaults/ruby
+# Exception `LoadError' at
+# <internal:/usr/pkg/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85 -
+# cannot load such file -- rubygems/defaults/operating_system
+# Exception `LoadError' at
+# <internal:/usr/pkg/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:162 -
+# cannot load such file -- rubygems/defaults/operating_system
+# Failed to execute epubcheck
+
+CLEANFILES+= ${EPUB_OUT}
+${EPUB_OUT}: Gemfile.lock ${EPUB_ADOC_TOTAL}
+ ${BUNDLE} exec asciidoctor-epub3 \
+ -v \
+ -d book \
+ -o ${.TARGET} \
+ -a producer="${PUBLISHER}" \
+ -a front-cover-image=${EPUB_COVER_FILE} \
+ -a ebook-format=epub3 \
+ -a media=${MEDIA} \
+ -a text-align=justify \
+ ${EPUB_ADOC_TOTAL}
+
+# XXX Needs to be different from the PDF one
+CLEANFILES+= ${EPUB_ADOC_TOTAL}
+${EPUB_ADOC_TOTAL}: ${CHAPTERS}
+ rm -f ${.TARGET}
+.for chapter in ${CHAPTERS}
+ dos2unix < ${chapter} | sed -E \
+ -e 's,[[:space:]]--[[:space:]],\&\#8212;,g' \
+ -e 's,\&iuml;,\&\#239;,g' \
+ -e 's,\&eacute;,\&\#233;,g' >> ${.TARGET}
+ printf '\n\n' >> ${.TARGET}
+.endfor
+
+########## ########## ##########
+
Gemfile.lock:
${BUNDLE} install