diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-05-01 09:13:23 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-05-01 09:13:23 +0200 |
commit | 7866f2f05e72b3eef1c593d63730d9b74b4dc3c8 (patch) | |
tree | 2946dcc5297c981ea0b1b3a517bc42b0d131b4d1 /_make/quarto.mk | |
parent | 090abfc12164c25626c472808122673f71a503f9 (diff) |
implement page count
Diffstat (limited to '_make/quarto.mk')
-rw-r--r-- | _make/quarto.mk | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/_make/quarto.mk b/_make/quarto.mk index d52d813..63ad617 100644 --- a/_make/quarto.mk +++ b/_make/quarto.mk @@ -1,4 +1,4 @@ -# Make snippet for exchanging data with a HedgeDoc pad +# Make snippet for rendering Quarto documents # # Copyright 2024, Jonas Smedegaard <dr@jones.dk> # SPDX-License-Identifier: GPL-3+ @@ -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-%) |