From a65eaaf76d773abbc9b05f3ff290f553323f4666 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 20 Apr 2025 22:09:21 +0200 Subject: compute page count --- _make/quarto.mk | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/_make/quarto.mk b/_make/quarto.mk index 1bea475..63ad617 100644 --- a/_make/quarto.mk +++ b/_make/quarto.mk @@ -22,9 +22,10 @@ # research/deep/superconductors # research/deep/fringe -# regular expression anchored at the beginning of a single line, +# regular expressions anchored at the beginning of a single line, # to match the beginning of content in document to omit from counting DOCUMENT_APPENDIX_REGEX ?= Appendix\\b +DOCUMENT_BIBLIOGRAPHY_REGEX ?= Bibliography\\b $(DOCUMENTS:%=doc-render-%): doc-render-%: %.qmd quarto render $< @@ -41,4 +42,15 @@ $(DOCUMENTS:%=doc-charcount-of-%): doc-charcount-of-%: %.qmd | perl -nsE 'next if /^-*$$/; $$done += /^$$re/; $$chars += length unless $$done; END { say $$chars }' \ -- -re="$(DOCUMENT_APPENDIX_REGEX)" -.PHONY: $(DOCUMENTS:%=doc-render-%) $(DOCUMENTS:%=doc-screening-of-%) $(DOCUMENTS:%=doc-charcount-of-%) +# count all characters except horisontal rulers, +# until bibliography, +# divide by 2400 and floor the result +$(DOCUMENTS:%=doc-pagecount-of-%): doc-pagecount-of-%: %.qmd + QUARTO_LOG_LEVEL=quiet \ + quarto render $< --to plain --columns=9999 --output - \ + | perl -nsE 'next if /^-*$$/; $$done += /^$$re/; $$chars += length unless $$done; END { say $$chars }' \ + -- -re="$(DOCUMENT_BIBLIOGRAPHY_REGEX)" \ + | perl -nE 'say int($$_ / 2400)' + +.PHONY: $(DOCUMENTS:%=doc-render-%) $(DOCUMENTS:%=doc-screening-of-%) \ + $(DOCUMENTS:%=doc-charcount-of-%) $(DOCUMENTS:%=doc-pagecount-of-%) -- cgit v1.2.3