diff --git a/csaf_2.1/prose/edit/Makefile b/csaf_2.1/prose/edit/Makefile index c3b531d2..1965b729 100644 --- a/csaf_2.1/prose/edit/Makefile +++ b/csaf_2.1/prose/edit/Makefile @@ -1,5 +1,5 @@ .DEFAULT_GOAL := build -.PHONY: build +.PHONY: build pdf build: bin/volatile.py cp -a build/tmp.md ../share/csaf-v2.1-draft.md @@ -7,3 +7,12 @@ build: bin/toccata.py timeout 2 tidy -config etc/tidy-config.txt build/injected.html -ashtml | sed 's///g;' > ../share/csaf-v2.1-draft.html git status + +pdf: + bin/lapidify.py + mkdir -p build/render/pdf + cp -a build/bookmatter.tex.in build/render/pdf/ + cp -a build/driver.tex.in build/render/pdf/ + cp -a build/metadata.tex.in build/render/pdf/ + cp -a build/setup.tex.in build/render/pdf/ + cd build/render/pdf && liitos render ../../ -t csaf -f pdf -p -l "etiketti -e" && open this.pdf && cd - diff --git a/csaf_2.1/prose/edit/bin/lapidify.py b/csaf_2.1/prose/edit/bin/lapidify.py new file mode 100755 index 00000000..d8a6b91c --- /dev/null +++ b/csaf_2.1/prose/edit/bin/lapidify.py @@ -0,0 +1,646 @@ +#! /usr/bin/env python +"""Lapidify - turning markdown to stone (PDF).""" +import json +import pathlib +import re +import os +import sys +from typing import Union + +import yaml + +ENCODING = 'utf-8' +NL = '\n' +CB_END = '}' +COLON = ':' +DASH = '-' +DOT = '.' +FULL_STOP = '.' +HASH = '#' +PARA = '§' +SEMI = ';' +SPACE = ' ' +TM = '™' + +# Optionally dump the look-up tables (LUT)s for section display and label: +DUMP_LUT = bool(os.getenv('DUMP_LUT', '')) + +# Configuration and runtime parameter candidates: +BINDER_AT = pathlib.Path('etc') / 'bind.txt' +SOURCE_AT = pathlib.Path('src') +BUILD_AT = pathlib.Path('build') +SECTION_DISPLAY_TO_LABEL_AT = pathlib.Path('etc') / 'section-display-to-label.json' +SECTION_LABEL_TO_DISPLAY_AT = pathlib.Path('etc') / 'section-label-to-display.json' +EG_GLOBAL_TO_LABEL_AT = pathlib.Path('etc') / 'example-global-to-local.json' +EG_LABEL_TO_GLOBAL_AT = pathlib.Path('etc') / 'example-local-to-global.json' + +# Parsers and magical literals: +IS_CITE_REF = 'cite' +CITE_REF_DETECT = re.compile(r'\[(?Pcite)\]\(#(?P