EPUB: Populate acknowledgements.md with contributors
Use liquid-lua to generate acknowledgements_epub.md, which is used by pandoc to build the EPUB book. Also stop using the '{%-' / '-%}' syntax, which liquid-lua does not support, in templates. Also add a vertical space between the first bullet in each bulleted list so pandoc recognizes bulleted lists as such. This has no effect on the the website.
This commit is contained in:
parent
80ba7fdfec
commit
99aa26401f
7 changed files with 73 additions and 26 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -26,3 +26,7 @@ Gemfile.lock
|
||||||
|
|
||||||
## Emacs files
|
## Emacs files
|
||||||
auto/
|
auto/
|
||||||
|
|
||||||
|
## Misc build files
|
||||||
|
out/
|
||||||
|
src/plfa/acknowledgements_epub.md
|
||||||
|
|
|
@ -22,6 +22,7 @@ addons:
|
||||||
packages:
|
packages:
|
||||||
- libgmp-dev
|
- libgmp-dev
|
||||||
- libicu-dev
|
- libicu-dev
|
||||||
|
- luarocks
|
||||||
|
|
||||||
# Ensure we run BASH and not SH
|
# Ensure we run BASH and not SH
|
||||||
env:
|
env:
|
||||||
|
|
24
Makefile
24
Makefile
|
@ -49,12 +49,10 @@ out/:
|
||||||
# sections are displayed to users. Some readers may be slow if the chapter
|
# sections are displayed to users. Some readers may be slow if the chapter
|
||||||
# files are too large, so for large documents with few level-1 headings, one
|
# files are too large, so for large documents with few level-1 headings, one
|
||||||
# might want to use a chapter level of 2 or 3."
|
# might want to use a chapter level of 2 or 3."
|
||||||
#
|
|
||||||
#TODO: embedded fonts not working (path problem?)
|
|
||||||
|
|
||||||
epub: out/plfa.epub
|
epub: out/plfa.epub
|
||||||
|
|
||||||
out/plfa.epub: out/ $(AGDA) $(LUA) epub/main.css
|
out/plfa.epub: out/ $(AGDA) $(LUA) epub/main.css src/plfa/acknowledgements_epub.md
|
||||||
pandoc --strip-comments \
|
pandoc --strip-comments \
|
||||||
--css=epub/main.css \
|
--css=epub/main.css \
|
||||||
--epub-embed-font='assets/fonts/mononoki.woff' \
|
--epub-embed-font='assets/fonts/mononoki.woff' \
|
||||||
|
@ -62,6 +60,7 @@ out/plfa.epub: out/ $(AGDA) $(LUA) epub/main.css
|
||||||
--epub-embed-font='assets/fonts/DejaVuSansMono.woff' \
|
--epub-embed-font='assets/fonts/DejaVuSansMono.woff' \
|
||||||
--lua-filter epub/include-files.lua \
|
--lua-filter epub/include-files.lua \
|
||||||
--lua-filter epub/rewrite-links.lua \
|
--lua-filter epub/rewrite-links.lua \
|
||||||
|
--lua-filter epub/rewrite-html-ul.lua \
|
||||||
--lua-filter epub/default-code-class.lua -M default-code-class=agda \
|
--lua-filter epub/default-code-class.lua -M default-code-class=agda \
|
||||||
--standalone \
|
--standalone \
|
||||||
--fail-if-warnings \
|
--fail-if-warnings \
|
||||||
|
@ -70,7 +69,8 @@ out/plfa.epub: out/ $(AGDA) $(LUA) epub/main.css
|
||||||
-o "$@" \
|
-o "$@" \
|
||||||
epub/index.md
|
epub/index.md
|
||||||
|
|
||||||
|
src/plfa/acknowledgements_epub.md: src/plfa/acknowledgements.md _config.yml
|
||||||
|
lua epub/run-liquid.lua _config.yml $< > $@
|
||||||
|
|
||||||
|
|
||||||
# Convert literal Agda to Markdown
|
# Convert literal Agda to Markdown
|
||||||
|
@ -119,7 +119,7 @@ build-incremental: $(MARKDOWN)
|
||||||
|
|
||||||
# Remove all auxiliary files
|
# Remove all auxiliary files
|
||||||
clean:
|
clean:
|
||||||
rm -f .agda-stdlib.sed .links-*.sed
|
rm -f .agda-stdlib.sed .links-*.sed src/plfa/acknowledgements_epub.md
|
||||||
ifneq ($(strip $(AGDAI)),)
|
ifneq ($(strip $(AGDAI)),)
|
||||||
rm $(AGDAI)
|
rm $(AGDAI)
|
||||||
endif
|
endif
|
||||||
|
@ -158,6 +158,9 @@ travis-setup:\
|
||||||
$(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION)/src\
|
$(HOME)/agda-stdlib-$(AGDA_STDLIB_VERSION)/src\
|
||||||
$(HOME)/.agda/defaults\
|
$(HOME)/.agda/defaults\
|
||||||
$(HOME)/.agda/libraries\
|
$(HOME)/.agda/libraries\
|
||||||
|
$(HOME)/.local/share/lua/5.1/tinyyaml.lua\
|
||||||
|
$(HOME)/.local/share/lua/5.1/liquid.lua\
|
||||||
|
$(HOME)/.local/share/lua/5.1/cjson\
|
||||||
/usr/bin/pandoc
|
/usr/bin/pandoc
|
||||||
|
|
||||||
.phony: travis-setup
|
.phony: travis-setup
|
||||||
|
@ -204,6 +207,17 @@ $(HOME)/.local/bin/agda:
|
||||||
cd $(HOME)/agda-$(AGDA_VERSION);\
|
cd $(HOME)/agda-$(AGDA_VERSION);\
|
||||||
stack install --stack-yaml=stack-8.0.2.yaml
|
stack install --stack-yaml=stack-8.0.2.yaml
|
||||||
|
|
||||||
|
$(HOME)/.local/share/lua/5.1/tinyyaml.lua:
|
||||||
|
luarocks install lua-tinyyaml
|
||||||
|
|
||||||
|
$(HOME)/.local/share/lua/5.1/liquid.lua:
|
||||||
|
luarocks install liquid
|
||||||
|
|
||||||
|
$(HOME)/.local/share/lua/5.1/cjson:
|
||||||
|
# Only this particular version works:
|
||||||
|
# https://github.com/mpx/lua-cjson/issues/56:
|
||||||
|
luarocks install lua-cjson 2.1.0-1
|
||||||
|
|
||||||
travis-uninstall-agda:
|
travis-uninstall-agda:
|
||||||
rm -rf $(HOME)/agda-$(AGDA_VERSION)/
|
rm -rf $(HOME)/agda-$(AGDA_VERSION)/
|
||||||
rm -f $(HOME)/.local/bin/agda
|
rm -f $(HOME)/.local/bin/agda
|
||||||
|
|
|
@ -65,7 +65,7 @@ src/plfa/part2/Substitution.lagda.md
|
||||||
# Backmatter
|
# Backmatter
|
||||||
|
|
||||||
``` {.include shift-heading-level-by=1}
|
``` {.include shift-heading-level-by=1}
|
||||||
src/plfa/acknowledgements.md
|
src/plfa/acknowledgements_epub.md
|
||||||
src/plfa/Fonts.lagda.md
|
src/plfa/Fonts.lagda.md
|
||||||
src/plfa/statistics.md
|
src/plfa/statistics.md
|
||||||
```
|
```
|
||||||
|
|
5
epub/rewrite-html-ul.lua
Normal file
5
epub/rewrite-html-ul.lua
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- Transforms '<ul class={something}>' into '<ul>'.
|
||||||
|
function RawBlock (el)
|
||||||
|
el.text = el.text:gsub('%s*<%s*ul%s*class=%s*"?[%w-]+"?%s*>%s*', '<ul>')
|
||||||
|
return el
|
||||||
|
end
|
19
epub/run-liquid.lua
Normal file
19
epub/run-liquid.lua
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
local yaml = require 'tinyyaml'
|
||||||
|
local liquid = require 'liquid'
|
||||||
|
|
||||||
|
if #arg ~= 2 then
|
||||||
|
print('usage: ' .. arg[0] .. ' [yaml_file] [markdown_file]')
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 1. Read YAML metadata from file, which we nest under the key 'site'.
|
||||||
|
local metadata = { ['site'] = yaml.parse(io.open(arg[1]):read('a')) }
|
||||||
|
|
||||||
|
-- 2. Read markdown document from file.
|
||||||
|
local document = io.open(arg[2]):read('a')
|
||||||
|
|
||||||
|
-- 3. Render the markdown document with the YAML metadata as context.
|
||||||
|
local template = liquid.Template:parse(document)
|
||||||
|
local result = template:render(liquid.InterpreterContext:new(metadata))
|
||||||
|
|
||||||
|
print(result)
|
|
@ -7,12 +7,14 @@ next : /Fonts/
|
||||||
---
|
---
|
||||||
|
|
||||||
Thank you to:
|
Thank you to:
|
||||||
* The inventors of Agda, for a new playground.
|
|
||||||
* The authors of Software Foundations, for inspiration.
|
* The inventors of Agda, for a new playground.
|
||||||
|
* The authors of Software Foundations, for inspiration.
|
||||||
|
|
||||||
|
|
||||||
A special thank you, for inventing ideas on which
|
A special thank you, for inventing ideas on which
|
||||||
this book is based, and for hand-holding:
|
this book is based, and for hand-holding:
|
||||||
|
|
||||||
<ul class="list-of-contributors">
|
<ul class="list-of-contributors">
|
||||||
<li>Andreas Abel</li>
|
<li>Andreas Abel</li>
|
||||||
<li>Catarina Coquand</li>
|
<li>Catarina Coquand</li>
|
||||||
|
@ -25,32 +27,34 @@ this book is based, and for hand-holding:
|
||||||
<li>Ulf Norell</li>
|
<li>Ulf Norell</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{%- if site.contributors or site.extra_contributors -%}
|
{% if site.contributors or site.extra_contributors %}
|
||||||
For pull requests big and small, and for answering questions on the Agda mailing list:
|
For pull requests big and small, and for answering questions on the Agda mailing list:
|
||||||
|
|
||||||
<ul class="list-of-contributors">
|
<ul class="list-of-contributors">
|
||||||
{%- for contributor in site.contributors -%}
|
{% for contributor in site.contributors %}
|
||||||
<li><a href="https://github.com/{{ contributor.github_username }}">{{ contributor.name }}</a></li>
|
<li><a href="https://github.com/{{ contributor.github_username }}">{{ contributor.name }}</a></li>
|
||||||
{%- endfor -%}
|
{% endfor %}
|
||||||
{%- for contributor in site.extra_contributors -%}
|
{% for contributor in site.extra_contributors %}
|
||||||
{%- if contributor.name and contributor.github_username -%}
|
{% if contributor.name and contributor.github_username %}
|
||||||
<li><a href="https://github.com/{{ contributor.github_username }}">{{ contributor.name }}</a></li>
|
<li><a href="https://github.com/{{ contributor.github_username }}">{{ contributor.name }}</a></li>
|
||||||
{%- else -%}
|
{% else %}
|
||||||
{%- if contributor.name -%}
|
{% if contributor.name %}
|
||||||
<li>{{ contributor.name }}</li>
|
<li>{{ contributor.name }}</li>
|
||||||
{%- endif -%}
|
{% endif %}
|
||||||
{%- if contributor.github_username -%}
|
{% if contributor.github_username %}
|
||||||
<li><a href="https://github.com/{{ contributor.github_username }}">{{ contributor.github_username }}</a></li>
|
<li><a href="https://github.com/{{ contributor.github_username }}">{{ contributor.github_username }}</a></li>
|
||||||
{%- endif -%}
|
{% endif %}
|
||||||
{%- endif -%}
|
{% endif %}
|
||||||
{%- endfor -%}
|
{% endfor %}
|
||||||
<li>[Your name goes here]</li>
|
<li>[Your name goes here]</li>
|
||||||
</ul>
|
</ul>
|
||||||
{%- else -%}
|
{% else %}
|
||||||
{%- endif -%}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
For support:
|
For support:
|
||||||
* EPSRC Programme Grant EP/K034413/1
|
|
||||||
* NSF Grant No. 1814460
|
* EPSRC Programme Grant EP/K034413/1
|
||||||
* Foundation Sciences Mathematiques de Paris (FSMP)
|
* NSF Grant No. 1814460
|
||||||
|
* Foundation Sciences Mathematiques de Paris (FSMP)
|
||||||
Distinguised Professor Fellowship
|
Distinguised Professor Fellowship
|
Loading…
Reference in a new issue