$body$ From 64ff672300881c5af5e821b8ee23a59a24aa0a65 Mon Sep 17 00:00:00 2001 From: Wen Kokke Date: Tue, 24 Aug 2021 19:23:11 +0100 Subject: [PATCH 13/23] Removed superfluous metadata template. --- templates/metadata.md | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 templates/metadata.md diff --git a/templates/metadata.md b/templates/metadata.md deleted file mode 100644 index b3384a5e..00000000 --- a/templates/metadata.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -comment: This template is used to restore the standard PLFA metadata to Markdown files. It is used in raw writers. ---- - ---- -title : $title$ -$if(authors)$ -author : -$for(authors)$ - - $name$ -$endfor$ -$endif$ -description : $description$ -rights : $rights$ -language : $language$ -layout : $layout$ -prev : $prev$ -permalink : $permalink$ -next : $next$ ---- - -$body$ From b07957d430a47ddc53b1297dbbe1387642f36066 Mon Sep 17 00:00:00 2001 From: Wen Kokke Date: Tue, 24 Aug 2021 21:48:13 +0100 Subject: [PATCH 14/23] Fix EPUB. --- templates/metadata.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 templates/metadata.md diff --git a/templates/metadata.md b/templates/metadata.md new file mode 100644 index 00000000..0525bb38 --- /dev/null +++ b/templates/metadata.md @@ -0,0 +1,19 @@ +--- +comment: This file exists to save the correct metadata to the generated `epub.md` file. +--- + +--- +lang : $language$ +pagetitle : $pagetitle$ +title : $pagetitle$ +titlepage : true +description : $description$ +author : +$for(authors)$ +- $name$ +$endfor$ +date : $modified$ +rights : $rights$ +--- + +$body$ From a9f85c9ab16c3a1dfe25c69e5d2cc883791c4bc9 Mon Sep 17 00:00:00 2001 From: Wen Kokke Date: Tue, 24 Aug 2021 22:41:18 +0100 Subject: [PATCH 15/23] EPUB and PDF now more-or-less work --- Makefile | 82 +++++---- book/epub.css | 2 +- book/epub.md | 2 +- book/epub.mk | 19 +- book/lua/epub-clean-html.lua | 10 +- book/lua/include-files.lua | 51 ------ book/lua/single-file-headers.lua | 57 ------ book/lua/single-file-links.lua | 14 +- book/pdf.mk | 14 +- book/pdf.tex | 2 +- hs/Hakyll/Web/Agda.hs | 11 +- hs/Hakyll/Web/Template/Context/Derived.hs | 11 ++ hs/Main.hs | 211 ++++++++++++---------- plfa.cabal | 40 ++-- 14 files changed, 236 insertions(+), 290 deletions(-) delete mode 100644 book/lua/include-files.lua delete mode 100644 book/lua/single-file-headers.lua diff --git a/Makefile b/Makefile index 5f5e0fe8..207c94de 100644 --- a/Makefile +++ b/Makefile @@ -18,18 +18,15 @@ PANDOC := stack exec pandoc -- .PHONY: all all: - @echo "Building site..." - make build - @echo "Testing site..." - make test - @echo "Building epub..." - make epub-build - @echo "Testing epub..." - make epub-test - @echo "Building pdf..." - make pdf-build - @echo "Testing pdf..." + @make build + @make epub-build + @make pdf-build +.PHONY: all-clean +all-clean: + @make clean + @make epub-clean + @make pdf-clean ################################################################################# # Setup Git Hooks @@ -37,7 +34,8 @@ all: .PHONY: init init: setup-check-fix-whitespace setup-install-htmlproofer - git config core.hooksPath .githooks + @echo "Setting up Git Hooks" + @git config core.hooksPath .githooks ################################################################################# @@ -45,13 +43,14 @@ init: setup-check-fix-whitespace setup-install-htmlproofer ################################################################################# .PHONY: build -build: \ - standard-library/ChangeLog.md - stack build && stack exec site build +build: standard-library/ChangeLog.md + @echo "Building site" + @stack build && stack exec site build standard-library/ChangeLog.md: - git submodule init - git submodule update --recursive + @echo "Updating Agda standard library" + @git submodule init + @git submodule update --recursive ################################################################################# @@ -60,17 +59,18 @@ standard-library/ChangeLog.md: .PHONY: test test: setup-install-htmlproofer build - cd $(SITE_DIR) && htmlproofer \ - --check-html \ - --disable-external \ - --report-invalid-tags \ - --report-missing-names \ - --report-script-embeds \ - --report-missing-doctype \ - --report-eof-tags \ - --report-mismatched-tags \ - --check-img-http \ - --check-opengraph \ + @echo "Testing generated HTML using HTMLProofer" + @cd $(SITE_DIR) && htmlproofer \ + --check-html \ + --disable-external \ + --report-invalid-tags \ + --report-missing-names \ + --report-script-embeds \ + --report-missing-doctype \ + --report-eof-tags \ + --report-mismatched-tags \ + --check-img-http \ + --check-opengraph \ . @@ -79,9 +79,9 @@ test: setup-install-htmlproofer build ################################################################################# .PHONY: watch -watch: \ - standard-library/ChangeLog.md - stack build && stack exec site watch +watch: standard-library/ChangeLog.md + @echo "Watching for changes and rebuilding" + @stack build && stack exec site watch ################################################################################# @@ -90,7 +90,8 @@ watch: \ .PHONY: update-contributors update-contributors: - stack build && stack exec update-contributors + @echo "Updating contributors from GitHub" + @stack build && stack exec update-contributors ################################################################################# @@ -98,9 +99,9 @@ update-contributors: ################################################################################# .PHONY: clean -clean: \ - standard-library/ChangeLog.md - stack build && stack exec site clean +clean: standard-library/ChangeLog.md + @echo "Cleaning generated files for site" + @stack build && stack exec site clean ################################################################################# @@ -119,9 +120,7 @@ list: .PHONY: publish publish: setup-check-rsync - @echo "Building site..." - make build - @echo "Testing site..." + make all make test @echo "Creating web branch..." git fetch --all @@ -159,13 +158,16 @@ ifeq (,$(wildcard $(PLFA_AFS_DIR))) @exit 1 else ifeq (,$(wildcard $(PLFA_AFS_DIR)/html)) + @echo "Checkout latest version from GitHub" git clone https://github.com/plfa/plfa.github.io.git --branch web --single-branch --depth 1 html endif - cd $(PLFA_AFS_DIR)/html \ + @echo "Checkout latest version from GitHub" + @cd $(PLFA_AFS_DIR)/html \ && git fetch --depth 1 \ && git reset --hard origin/web \ && git clean -dfx - fsr setacl $(PLFA_AFS_DIR)/html system:groupwebserver rl + @echo "Setting permissions to include web server" + @fsr setacl $(PLFA_AFS_DIR)/html system:groupwebserver rl endif diff --git a/book/epub.css b/book/epub.css index b6a50a63..e6b7867b 100644 --- a/book/epub.css +++ b/book/epub.css @@ -4,7 +4,7 @@ font-family: 'DejaVu-mononoki-Symbola-Droid'; font-weight: normal; font-style: normal; - src: url('../public/webfonts/DejaVu-mononoki-Symbola-Droid.woff'); + src: url('../fonts/DejaVu-mononoki-Symbola-Droid.woff'); } body { diff --git a/book/epub.md b/book/epub.md index b130eca7..a973514e 100644 --- a/book/epub.md +++ b/book/epub.md @@ -2,6 +2,6 @@ $for(parts)$ # $title$ $for(sections)$ ## $title$ {#$anchor$} -$body$ +$shifted_raw$ $endfor$ $endfor$ diff --git a/book/epub.mk b/book/epub.mk index bc6e6cc2..57946cc3 100644 --- a/book/epub.mk +++ b/book/epub.mk @@ -15,24 +15,25 @@ FRANKENFONT := public/webfonts/DejaVu-mononoki-Symbola-Droid.woff # Compile PLFA to an EPUB using Pandoc ################################################################################# -.PHONY: epub-build +.PHONY: epub epub-build +epub: epub-build epub-build: $(SITE_DIR)/plfa.epub $(SITE_DIR)/plfa.epub: \ - $(EPUB_DIR)/epub.md $(EPUB_DIR)/epub.css $(RAW_DIR)/epub.xml $(FRANKENFONT) \ + $(RAW_DIR)/epub.md $(EPUB_DIR)/epub.css $(RAW_DIR)/epub.xml $(FRANKENFONT) \ $(MD_FILES) $(EPUB_LUA_SCRIPTS) | setup-install-pandoc - @$(PANDOC) \ + @echo "Building EPUB" + $(PANDOC) \ --strip-comments \ --css=$(EPUB_DIR)/epub.css \ --epub-embed-font=$(FRANKENFONT) \ - --epub-metadata=$(RAW_DIR)/epub.xml + --epub-metadata=$(RAW_DIR)/epub.xml \ --indented-code-class=default \ --lua-filter=$(EPUB_LUA_DIR)/set-default-code-class.lua -M default-code-class=agda \ --lua-filter=$(EPUB_LUA_DIR)/remove-badges.lua -M badge-url=https://img.shields.io/badge/ \ --lua-filter=$(EPUB_LUA_DIR)/epub-clean-html.lua \ --lua-filter=$(EPUB_LUA_DIR)/single-file-links.lua \ --standalone \ - --fail-if-warnings \ --toc --toc-depth=2 \ --epub-chapter-level=2 \ $< -o $@ @@ -44,7 +45,8 @@ $(SITE_DIR)/plfa.epub: \ .PHONY: epub-test epub-test: $(SITE_DIR)/plfa.epub | setup-check-epubcheck - epubcheck $(SITE_DIR)/plfa.epub + @echo "Testing EPUB with EPUBCheck" + @epubcheck $(SITE_DIR)/plfa.epub ################################################################################# @@ -52,7 +54,7 @@ epub-test: $(SITE_DIR)/plfa.epub | setup-check-epubcheck ################################################################################# $(RAW_DIR)/epub.xml: $(EPUB_DIR)/epub.xml - make build + @make build ################################################################################# @@ -61,7 +63,8 @@ $(RAW_DIR)/epub.xml: $(EPUB_DIR)/epub.xml .PHONY: epub-clean epub-clean: - rm -f $(SITE_DIR)/plfa.epub + @echo "Cleaning generated files for EPUB" + @rm -f $(SITE_DIR)/plfa.epub ################################################################################# diff --git a/book/lua/epub-clean-html.lua b/book/lua/epub-clean-html.lua index 5a83375a..0a42bbf7 100644 --- a/book/lua/epub-clean-html.lua +++ b/book/lua/epub-clean-html.lua @@ -1,5 +1,5 @@ --- Transforms '