diff --git a/Makefile.am b/Makefile.am index 36311a2b..6f4f3675 100644 --- a/Makefile.am +++ b/Makefile.am @@ -74,7 +74,7 @@ fontsdir = $(datadir)/fonts dist_fonts_DATA = fonts/Almendra-Bold.otf fonts/Almendra-BoldItalic.otf fonts/Almendra-Italic.otf fonts/Almendra-Regular.otf fonts/AlmendraDisplay-Regular.otf fonts/AlmendraSC-Bold.otf fonts/AlmendraSC-BoldItalic.otf fonts/AlmendraSC-Italic.otf fonts/AlmendraSC-Regular.otf fonts/FeFlow2.otf fonts/NexaRustExtras-Free.otf fonts/NexaRustHandmade-Extended-Free.otf fonts/NexaRustSans-Black-Free.otf fonts/NexaRustScriptL-0-Free.otf fonts/NexaRustSlab-BlackShadow01-Free.otf fonts/Nymphette.ttf fonts/PrintersOrnamentsOne.ttf filtersdir = $(datadir)/pandoc-filters -dist_filters_DATA = pandoc-filters/chapterid.lua pandoc-filters/epubclean.lua pandoc-filters/svg2pdf.py pandoc-filters/withoutfootnotes.lua pandoc-filters/withoutheadinglinks.lua pandoc-filters/withoutlinks.lua pandoc-filters/withverses.lua +dist_filters_DATA = pandoc-filters/chapterid.lua pandoc-filters/epubclean.lua pandoc-filters/strip_for_mdbook.lua pandoc-filters/svg2pdf.py pandoc-filters/withoutfootnotes.lua pandoc-filters/withoutheadinglinks.lua pandoc-filters/withoutlinks.lua pandoc-filters/withverses.lua packagesdir = $(datadir)/packages dist_packages_DATA = packages/crop.lua packages/markdown.lua packages/verseindex.lua diff --git a/pandoc-filters/strip_for_mdbook.lua b/pandoc-filters/strip_for_mdbook.lua new file mode 100644 index 00000000..028d734b --- /dev/null +++ b/pandoc-filters/strip_for_mdbook.lua @@ -0,0 +1,22 @@ +-- c.f. pandoc-filters/withoutheadinglinks.lua +Header = function (element) + return pandoc.walk_block(element, { + -- c.f. pandoc-filters/epubclean.lua + Note = function (_) + return {} + end, + Link = function (element) + return element.content + end + }) +end + +function remove_attr (element) + if element.attr then + element.attr = pandoc.Attr() + return element + end +end + +Inline = remove_attr +Block = remove_attr diff --git a/scripts/split_mdbook_src.zsh.in b/scripts/split_mdbook_src.zsh.in index abe0fa61..c3f0639d 100644 --- a/scripts/split_mdbook_src.zsh.in +++ b/scripts/split_mdbook_src.zsh.in @@ -15,8 +15,12 @@ function trunc() { trunc $dir/$of -@PANDOC@ $src --markdown-headings=atx --wrap=none --to=commonmark_x-smart+gfm_auto_identifiers --reference-location=section | -@PERL@ -pne 's/{osis=".*"}//g' | +@PANDOC@ $src \ + --markdown-headings=atx \ + --wrap=none \ + --reference-location=section \ + --to=commonmark_x-smart \ + --lua-filter=$CASILEDIR/pandoc-filters/strip_for_mdbook.lua | while read line; do unset title slug # Check for chapter header