From ae7bcb4277d6ce225516bcf36ef07451fe2be2ee Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sun, 25 Oct 2020 16:22:54 -0600 Subject: increase pandoc fanciness --- .build.yml | 16 ++++-- .gitignore | 1 + LICENSE.md | 4 ++ README.md | 2 - etc/md.yml | 14 ++--- etc/pdf.yml | 18 +++---- etc/process-md.lua | 7 +++ etc/process-pdf.lua | 0 etc/template.html | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.md | 2 - syntax.md | 2 - 11 files changed, 193 insertions(+), 26 deletions(-) create mode 100644 .gitignore create mode 100644 etc/process-md.lua create mode 100644 etc/process-pdf.lua create mode 100644 etc/template.html diff --git a/.build.yml b/.build.yml index 9f036aa..5af08b4 100644 --- a/.build.yml +++ b/.build.yml @@ -8,12 +8,22 @@ sources: tasks: - page-count: | cd crowbar-spec - files="index vs-c tagged-unions types safety errors syntax" + files="index vs-c tagged-unions types safety errors syntax LICENSE" + html_files="" + i=0 for file in $files do - pandoc --defaults=etc/md.yml -o $file.html $file.md + pandoc --defaults=etc/md.yml --number-offset=$i -o $file.html $file.md + html_files="$html_files $file.html" + i=$((i+1)) done - pandoc --defaults=etc/pdf.yml -o ../spec.pdf *.html + if git describe --tags --exact-match 2>/dev/null + then + metadata="subtitle=$(git describe --tags --exact-match)" + else + metadata="version=$(git log -1 --no-decorate --oneline)" + fi + pandoc --defaults=etc/pdf.yml -o ../spec.pdf -M $metadata $html_files cd .. pdfinfo spec.pdf | grep Pages tar czvf spec-html.tar.gz crowbar-spec/*.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b61c8c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/*.html diff --git a/LICENSE.md b/LICENSE.md index 431007a..1d968be 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,2 +1,6 @@ +--- +title: License +--- + [![Creative Commons BY-SA License](https://i.creativecommons.org/l/by-sa/4.0/80x15.png)](http://creativecommons.org/licenses/by-sa/4.0/) This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/"). diff --git a/README.md b/README.md index 368eaeb..cc8cf90 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,3 @@ read the spec: reference compiler: play with the reference compiler: - -[![Creative Commons BY-SA License](https://i.creativecommons.org/l/by-sa/4.0/80x15.png)](http://creativecommons.org/licenses/by-sa/4.0/) diff --git a/etc/md.yml b/etc/md.yml index aece004..a918de3 100644 --- a/etc/md.yml +++ b/etc/md.yml @@ -1,23 +1,23 @@ from: markdown to: html5 +template: etc/template.html standalone: true -verbosity: INFO +filters: + - etc/process-md.lua -top-level-division: chapter +metadata: + lang: "en" -pdf-engine: weasyprint +verbosity: INFO table-of-contents: false number-sections: true shift-heading-level-by: 1 -title-prefix: "Crowbar Specification: " +title-prefix: "Crowbar Specification" eol: lf # syntax-definition: fail-if-warnings: true -dump-args: false -ignore-args: false -trace: false diff --git a/etc/pdf.yml b/etc/pdf.yml index 5ef3857..a76afca 100644 --- a/etc/pdf.yml +++ b/etc/pdf.yml @@ -1,20 +1,18 @@ from: html to: pdf -standalone: true +template: etc/template.html -metadata: - title: "Crowbar Specification" +filters: + - etc/process-pdf.lua -verbosity: INFO +metadata: + title-before-toc: true + title: "Crowbar Specification" -top-level-division: chapter +verbosity: WARNING pdf-engine: weasyprint table-of-contents: true - -fail-if-warnings: true -dump-args: false -ignore-args: false -trace: false +number-sections: false diff --git a/etc/process-md.lua b/etc/process-md.lua new file mode 100644 index 0000000..30c85de --- /dev/null +++ b/etc/process-md.lua @@ -0,0 +1,7 @@ +function Pandoc(doc) + local title_header = pandoc.Header(1, '') + local title = doc.meta.title + title_header.content = title + doc.blocks:insert(1, title_header) + return doc +end diff --git a/etc/process-pdf.lua b/etc/process-pdf.lua new file mode 100644 index 0000000..e69de29 diff --git a/etc/template.html b/etc/template.html new file mode 100644 index 0000000..61cefb4 --- /dev/null +++ b/etc/template.html @@ -0,0 +1,153 @@ + + + + + + + $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ + + + +$if(title-before-toc)$ +

$title$

+$if(subtitle)$ +

$subtitle$

+$endif$ +$if(version)$ +

from git: $version$

+$endif$ +$endif$ +$if(toc)$ + +$endif$ +$body$ + + diff --git a/index.md b/index.md index c95a888..f20cb69 100644 --- a/index.md +++ b/index.md @@ -37,5 +37,3 @@ TODO - [announcement mailing list](https://lists.sr.ht/~boringcactus/crowbar-lang-announce) - [permanent discussion mailing list](https://lists.sr.ht/~boringcactus/crowbar-lang-devel) - ephemeral discussions via IRC: #crowbar-lang on freenode ([join via irc](ircs://chat.freenode.net/#crowbar-lang), [join via web](https://webchat.freenode.net/#crowbar-lang)) - -[![Creative Commons BY-SA License](https://i.creativecommons.org/l/by-sa/4.0/80x15.png)](http://creativecommons.org/licenses/by-sa/4.0/) diff --git a/syntax.md b/syntax.md index 4641562..12e0b6c 100644 --- a/syntax.md +++ b/syntax.md @@ -348,5 +348,3 @@ Expression ← ComparisonExpression ('&&' ComparisonExpression)+ ComparisonExpression ('||' ComparisonExpression)+ / ComparisonExpression ``` - -[![Creative Commons BY-SA License](https://i.creativecommons.org/l/by-sa/4.0/80x15.png)](http://creativecommons.org/licenses/by-sa/4.0/) -- cgit v1.2.3