summaryrefslogtreecommitdiff
path: root/_make/quarto.mk
blob: 12ca445fbe743328d124bd0feccc7de36c01a541 (plain)
  1. # Make snippet for exchanging data with a HedgeDoc pad
  2. #
  3. # Copyright 2024, Jonas Smedegaard <dr@jones.dk>
  4. # SPDX-License-Identifier: GPL-3+
  5. #
  6. # Setup:
  7. # In main Makefile...
  8. # * set variable DOCUMENTS
  9. # * set variable DOCUMENT_APPENDIX_REGEX if needed
  10. # * include this make snippet
  11. #
  12. # Dependencies:
  13. # * quarto <https://quarto.org/>
  14. # * bat <https://github.com/sharkdp/bat>, with executable named "batcat"
  15. # * perl v5.10.1 or newer
  16. # list of relative paths to directories,
  17. # each containing an index.qmd file.
  18. #DOCUMENTS = \
  19. # main_paper \
  20. # promo_article \
  21. # research/deep/superconductors
  22. # research/deep/fringe
  23. # regular expression anchored at the beginning of a single line,
  24. # to match the beginning of content in document to omit from counting
  25. DOCUMENT_APPENDIX_REGEX ?= Appendix\\b
  26. $(DOCUMENTS:%=doc-render-%): doc-render-%: %/index.qmd
  27. quarto render $<
  28. $(DOCUMENTS:%=doc-screening-of-%): doc-screening-of-%: %/index.qmd
  29. QUARTO_LOG_LEVEL=quiet \
  30. quarto render $< --to markdown --output - | batcat --file-name index.qmd --language markdown
  31. # count all characters except horisontal rulers,
  32. # until appendices
  33. $(DOCUMENTS:%=doc-charcount-of-%): doc-charcount-of-%: %/index.qmd
  34. QUARTO_LOG_LEVEL=quiet \
  35. quarto render $< --to plain --columns=9999 --output - \
  36. | perl -nsE 'next if /^-*$$/; $$done += /^$$re/; $$chars += length unless $$done; END { say $$chars }' \
  37. -- -re="$(DOCUMENT_APPENDIX_REGEX)"
  38. .PHONY: $(DOCUMENTS:%=doc-render-%) $(DOCUMENTS:%=doc-screening-of-%) $(DOCUMENTS:%=doc-charcount-of-%)