From bbfd44eed29a858c1054c60b9fe5407d49de0c64 Mon Sep 17 00:00:00 2001 From: Stefan Hagen Date: Sun, 24 Nov 2024 00:09:48 +0100 Subject: [PATCH] Reworked boilerplate and spike for pdf-ication (WIP) Signed-off-by: Stefan Hagen --- csaf_2.1/prose/edit/Makefile | 11 +- csaf_2.1/prose/edit/bin/lapidify.py | 646 +++++++++++++++ csaf_2.1/prose/edit/etc/bind.txt | 12 +- .../edit/etc/section-display-to-label.json | 80 +- .../edit/etc/section-label-to-display.json | 84 +- csaf_2.1/prose/edit/src/acknowledgements.md | 2 +- .../prose/edit/src/additional-conventions.md | 9 +- csaf_2.1/prose/edit/src/conformance.md | 16 +- csaf_2.1/prose/edit/src/distributing.md | 56 +- csaf_2.1/prose/edit/src/guidance-on-size.md | 763 ++++++++++-------- ...uction-01-changes-from-earlier-versions.md | 3 + .../edit/src/introduction-01-ipr-policy.md | 7 - ...ry.md => introduction-02-glossary-data.md} | 0 .../edit/src/introduction-02-glossary.md | 3 + .../edit/src/introduction-02-terminology.md | 7 - ...troduction-05-typographical-conventions.md | 10 +- csaf_2.1/prose/edit/src/notices.md | 29 + csaf_2.1/prose/edit/src/profiles.md | 5 + csaf_2.1/prose/edit/src/references.md | 171 ++++ csaf_2.1/prose/edit/src/revision-history.md | 2 +- .../safety-security-and-data-protection.md | 8 + ...a-elements-01-defs-03-full-product-name.md | 67 +- .../schema-elements-01-defs-04-language.md | 9 +- .../src/schema-elements-01-defs-11-version.md | 20 +- ...chema-elements-02-props-03-product-tree.md | 5 +- ...ma-elements-02-props-04-vulnerabilities.md | 21 +- ...-24-multiple-definition-in-involvements.md | 6 +- ...-25-multiple-use-of-same-hash-algorithm.md | 18 +- .../src/tests-01-mndtr-27-profile-tests.md | 18 +- csaf_2.1/prose/edit/src/tests-02-optional.md | 40 +- .../prose/edit/src/tests-03-informative.md | 54 +- 31 files changed, 1651 insertions(+), 531 deletions(-) create mode 100755 csaf_2.1/prose/edit/bin/lapidify.py create mode 100644 csaf_2.1/prose/edit/src/introduction-01-changes-from-earlier-versions.md delete mode 100644 csaf_2.1/prose/edit/src/introduction-01-ipr-policy.md rename csaf_2.1/prose/edit/src/{introduction-02-terminology-glossary.md => introduction-02-glossary-data.md} (100%) create mode 100644 csaf_2.1/prose/edit/src/introduction-02-glossary.md delete mode 100644 csaf_2.1/prose/edit/src/introduction-02-terminology.md create mode 100644 csaf_2.1/prose/edit/src/notices.md create mode 100644 csaf_2.1/prose/edit/src/references.md diff --git a/csaf_2.1/prose/edit/Makefile b/csaf_2.1/prose/edit/Makefile index c3b531d28..1965b7297 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 000000000..d8a6b91c8 --- /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