diff options
| author | Joe Carstairs <me@joeac.net> | 2026-06-30 13:26:05 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-06-30 13:26:05 +0100 |
| commit | 080ffcc58edff91dad02ddc6cb1b3ce05ce2a5af (patch) | |
| tree | 5763f472acde5cc635db5e4573feca93e2b97a35 /Makefile | |
| parent | 0472a6fa83a0baa817ded401df41893af92831e8 (diff) | |
cooler wordcount function
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -14,6 +14,7 @@ SCRAPBOOK_MARKDOWN := scrapbook.md DISSERTATION_LATEX := dissertation.latex DISSERTATION_LATEX_NO_REFERENCES := dissertation-no-references.latex DISSERTATION_WORDCOUNT_FILE := .dissertation.wc +DISSERTATION_NO_REFERENCES_WORDCOUNT_FILE := .dissertation-no-references.wc DISSERTATION_PDF := dissertation.pdf DISSERTATION_PDF_NO_REFERENCES := dissertation-no-references.pdf LOG_PDF := log.pdf @@ -21,6 +22,13 @@ SCRAPBOOK_PDF := scrapbook.pdf chapter_markdown_file = chapter$(chapter_index).md chapter_wordcount_file = .chapter$(chapter_index).wc +chapter_wordcount = $(shell cat $(chapter_wordcount_file)) +chapter_wordcounts = $(foreach chapter_index,$(CHAPTER_INDICES),$(chapter_wordcount)) +chapter_wordcounts_sum = $$(( $(addsuffix " +",$(chapter_wordcounts)) 0 )) +dissertation_wordcount = $(shell cat $(DISSERTATION_WORDCOUNT_FILE)) +dissertation_no_references_wordcount = $(shell cat $(DISSERTATION_NO_REFERENCES_WORDCOUNT_FILE)) +footnotes_wordcount = $$(( $(dissertation_no_references_wordcount) - $(chapter_wordcounts_sum) )) +references_wordcount = $$(( $(dissertation_wordcount) - $(dissertation_no_references_wordcount) )) chapter_title = $(shell head -n 1 $(chapter_markdown_file) | cut -c4-) all: log scrapbook dissertation wordcount @@ -100,21 +108,27 @@ $(DISSERTATION_MARKDOWN): $(DISSERTATION_FRONTMATTER) $(CHAPTER_MARKDOWN_FILES) .SILENT: wordcount .PHONY: wordcount -wordcount: $(CHAPTER_WORDCOUNT_FILES) $(DISSERTATION_WORDCOUNT_FILE) +wordcount: $(CHAPTER_WORDCOUNT_FILES) $(DISSERTATION_WORDCOUNT_FILE) $(DISSERTATION_NO_REFERENCES_WORDCOUNT_FILE) $(foreach chapter_index,$(CHAPTER_INDICES), \ - echo "$(chapter_title): $(shell cat $(chapter_wordcount_file))"; \ + echo "$(chapter_title): $(chapter_wordcount)"; \ ) - echo "Footnotes: ???" - echo "References: ???" - echo "Total: $(shell cat $(DISSERTATION_WORDCOUNT_FILE))" + echo "Footnotes: $(footnotes_wordcount)" + echo "--------------------------------" + echo "Total: $(dissertation_no_references_wordcount)" + echo "--------------------------------" + echo "(References: $(references_wordcount))" $(CHAPTER_WORDCOUNT_FILE_PATTERN): $(CHAPTER_MARKDOWN_FILE_PATTERN) $(WORDCOUNT_FILTER) pandoc --lua-filter $(WORDCOUNT_FILTER) $< > $@ -$(DISSERTATION_WORDCOUNT_FILE): $(DISSERTATION_PDF_NO_REFERENCES) $(WORDCOUNT_FILTER) $(DISSERTATION_MARKDOWN) - echo "$(shell pdfgrep -o '\w+' $(DISSERTATION_PDF_NO_REFERENCES) | wc -w) ($(shell pandoc --lua-filter $(WORDCOUNT_FILTER) $(DISSERTATION_MARKDOWN)) + footnotes)" \ +$(DISSERTATION_WORDCOUNT_FILE): $(DISSERTATION_PDF) + pdfgrep -o '\w+' $(DISSERTATION_PDF) | wc -w \ > $(DISSERTATION_WORDCOUNT_FILE) +$(DISSERTATION_NO_REFERENCES_WORDCOUNT_FILE): $(DISSERTATION_PDF_NO_REFERENCES) + pdfgrep -o '\w+' $(DISSERTATION_PDF_NO_REFERENCES) | wc -w \ + > $(DISSERTATION_NO_REFERENCES_WORDCOUNT_FILE) + $(DISSERTATION_PDF_NO_REFERENCES): $(DISSERTATION_LATEX_NO_REFERENCES) pandoc \ --standalone \ |
