Skip to content

Commit

Permalink
fix(filters): Separate pandoc filter arguments from normalization arg…
Browse files Browse the repository at this point in the history
…uments
  • Loading branch information
alerque committed Aug 14, 2024
1 parent 48ec935 commit c17ae03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions rules/mdbook.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ $(MDBOOKS): %.mdbook: $(BUILDDIR)/%.mdbook/src/SUMMARY.md $(BUILDDIR)/%.mdbook/b

DISTDIRS += $(MDBOOKS)

$(BUILDDIR)/%-mdbook.md: private PANDOCFILTERARGS = --wrap=none --to=commonmark_x-smart
$(BUILDDIR)/%-mdbook.md: private PANDOCNORMALIZEARGS = --wrap=none --to=commonmark_x-smart
$(BUILDDIR)/%-mdbook.md: private PANDOCFILTERS += --lua-filter=$(CASILEDIR)/pandoc-filters/strip_for_mdbook.lua
$(BUILDDIR)/%-mdbook.md: $(BUILDDIR)/%-$(_processed).md
$(PANDOC) \
$(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERARGS) \
$(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERSARGS) $(PANDOCNORMALIZEARGS) \
$(filter %.md,$^) -o $@

$(BUILDDIR)/%.mdbook/src/SUMMARY.md: $(BUILDDIR)/%-mdbook.md
Expand Down
11 changes: 7 additions & 4 deletions rules/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,13 @@ endif
SILEPATH += $(CASILEDIR)

# Extra arguments to pass to Pandoc
PANDOCARGS ?= --wrap=preserve --markdown-headings=atx --top-level-division=chapter
PANDOCARGS ?= --top-level-division=chapter
PANDOCARGS += --wrap=preserve
PANDOCARGS += --markdown-headings=atx
PANDOCARGS += --reference-location=section
PANDOCNORMALIZEARGS ?= --from markdown-space_in_atx_header+ascii_identifiers+four_space_rule --to markdown-smart-four_space_rule
PANDOCFILTERS ?=
PANDOCFILTERARGS ?= --from markdown-space_in_atx_header+ascii_identifiers+four_space_rule --to markdown-smart-four_space_rule
PANDOCFILTERARGS ?=

# For when perl one-liners need Unicode compatibility
PERLARGS ?= -Mutf8 -CS
Expand Down Expand Up @@ -519,7 +522,7 @@ SOURCESWITHEDITS := $(SOURCESWITHVERSES) $(SOURCESWITHOUTFOOTNOTES) $(SOURCESWIT
$(SOURCESWITHEDITS): $$(call strip_edits,$$@)
: $(or $(filter %.md,$^),$(error No sources with expected edits defined))
$(PANDOC) \
$(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERARGS) \
$(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERARGS) $(PANDOCNORMALIZEARGS) \
$(filter %.md,$^) -o $@

# Configure SILE arguments to include common Lua libraries
Expand All @@ -540,7 +543,7 @@ $(BUILDDIR)/%-$(_processed).md: %.md $$(wildcard $(PROJECT)*.md $$*-$(_chapters)
$(PERL) $(PERLARGS) -pne "s/(?<=[\)\}])'/’/g" | # Work around Pandoc bug, see https://github.com/jgm/pandoc/issues/5385
$(call criticToSile) |
$(PANDOC) \
$(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERARGS) |
$(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERARGS) $(PANDOCNORMALIZEARGS) |
$(call markdown_hook) > $@

%-$(_booklet).pdf: $(BUILDDIR)/%-$(_spineless).pdf
Expand Down
2 changes: 1 addition & 1 deletion rules/utilities.mk
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ normalize_files:
basename $${src} | $(PERL) -pne 's/-.*$$//' | read chapno
dirname $${src} | read dir
$(SED) -n '/^#/{s/ı/i/g;p}' $${src} |
$(PANDOC) $(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERARGS) | read identifier
$(PANDOC) $(PANDOCARGS) $(PANDOCFILTERS) $(PANDOCFILTERARGS) $(PANDOCNORMALIZEARGS) | read identifier
target="$${dir}/$${chapno}-$${identifier}.md"
[[ $${src} == $${target} ]] || $(GIT) mv "$${src}" "$${target}"
done
Expand Down

0 comments on commit c17ae03

Please sign in to comment.