diff --git a/Makefile.am b/Makefile.am index 47ab6de5..526c902e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -68,7 +68,7 @@ dist_vim_DATA = citation_audit.vim quotation_audit.vim dist_data_DATA = functions.zsh scriptsdir = $(datadir)/scripts -dist_scripts_SCRIPTS = scripts/branch2criticmark.zsh scripts/cover_title.py scripts/diff2marked.zsh scripts/extract_references.js scripts/figure_dash.pl scripts/isbn_format.py scripts/italic_reorder.pl scripts/lazy_quotes.pl scripts/link_verses.js scripts/loadchapters.zsh scripts/msword_escapes.pl scripts/normalize_references.js scripts/ordinal_spaces.pl scripts/renumber_footnotes.pl scripts/reorder_punctuation.pl scripts/series_sort.lua scripts/smart_quotes.pl scripts/split_chapters.zsh scripts/stats.zsh scripts/toc2breaks.lua scripts/unicode_symbols.pl scripts/worklog.zsh +dist_scripts_SCRIPTS = scripts/branch2criticmark.zsh scripts/cover_title.py scripts/diff2marked.zsh scripts/extract_references.js scripts/figure_dash.pl scripts/isbn_format.py scripts/italic_reorder.pl scripts/lazy_quotes.pl scripts/link_verses.js scripts/loadchapters.zsh scripts/msword_escapes.pl scripts/normalize_references.js scripts/ordinal_spaces.pl scripts/renumber_footnotes.pl scripts/reorder_punctuation.pl scripts/series_sort.lua scripts/smart_quotes.pl scripts/split_chapters.zsh scripts/split_mdbook_src.zsh scripts/stats.zsh scripts/toc2breaks.lua scripts/unicode_symbols.pl scripts/worklog.zsh 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 diff --git a/configure.ac b/configure.ac index cb3b4156..c69aae28 100644 --- a/configure.ac +++ b/configure.ac @@ -182,6 +182,7 @@ AX_SCRIPT([reorder_punctuation.pl]) AX_SCRIPT([series_sort.lua]) AX_SCRIPT([smart_quotes.pl]) AX_SCRIPT([split_chapters.zsh]) +AX_SCRIPT([split_mdbook_src.zsh]) AX_SCRIPT([stats.zsh]) AX_SCRIPT([toc2breaks.lua]) AX_SCRIPT([unicode_symbols.pl]) diff --git a/scripts/split_mdbook_src.zsh.in b/scripts/split_mdbook_src.zsh.in new file mode 100644 index 00000000..903424e1 --- /dev/null +++ b/scripts/split_mdbook_src.zsh.in @@ -0,0 +1,35 @@ +#!@ZSH@ +set -e +set -x + +src=$1 +dir=$2 + +echo -e "# Summary\n\n" + +i=0 +of=00.md + +function trunc() { + : > $1 +} + +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' | +while read line; do + # Check for chapter header + if [[ $line =~ "^# .*" ]]; then + [[ $line =~ ".*unnumbered.*" ]] || let i=$i+1 + @PERL@ -pne 's/^# (.*) {.*#([-\w]+).*}/\2 \1/' <<< "$line" | + read slug title + test -n "$slug" + test -n "$title" + of=$(printf %02d $i)-$slug.md + trunc $dir/$of + line="# $title" + echo "[$title](./$of)" + fi + >> $dir/$of <<< $line +done