Skip to content

Commit

Permalink
feat(mdbook): Strip out input elements mdbook can't handle
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Apr 1, 2022
1 parent 5fe4233 commit ec1de6b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions pandoc-filters/strip_for_mdbook.lua
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions scripts/split_mdbook_src.zsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec1de6b

Please sign in to comment.