A company that writes with LaTeX ends up with a document class, a letter class and a presentation theme that share a design and not a line of code. Every fix is then made three times, two of them late and the third never. Here the page is written once. A company declares its colours, faces and logo in one file, and the document template, the letter class and the presentation theme read that one file. Nothing in the suite carries a colour value, a font name or a file name of any company, which is what lets it be published while the companies stay private. Every measure of the page follows from a measurement or from a named definition: the room the head and the foot need is taken from the boxes they really build, one line of the body text stands between the head and the text and between the text and the foot, a heading never stands alone at the foot of a page, a picture takes the size of the family, and a Markdown file reaches the same page as the same document written in LaTeX. The suite ships with a company that does not exist, Nordwind AG, so that it builds and is measured anywhere: three colours, the TeX Gyre families every installation carries, and an icon drawn in TikZ. 574 checks over five measurements, all of them on the rendered page or on the build log rather than on the source. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
34 lines
1.3 KiB
Lua
34 lines
1.3 KiB
Lua
-- Copyright (c) 2026 Marc Wäckerlin. SPDX-License-Identifier: MIT
|
|
-- Every drawing a document shows, converted while pandoc reads the document.
|
|
--
|
|
-- graphicx cannot read an SVG, and pandoc's own answer to one is the svg
|
|
-- package, which calls inkscape from inside the LaTeX run and therefore needs
|
|
-- shell escape — a document could then run any command it likes. So the drawing
|
|
-- is converted here, before a single line of LaTeX exists, and the picture in
|
|
-- the document points at the PDF that comes out.
|
|
--
|
|
-- The two directories arrive in the environment, from the converter: where the
|
|
-- document lies, and where the build may write.
|
|
|
|
local build = os.getenv('MD2PDF_BUILD')
|
|
local source = os.getenv('MD2PDF_SOURCE_DIR')
|
|
|
|
local function absolute(file)
|
|
return file:sub(1, 1) == '/' and file or source .. '/' .. file
|
|
end
|
|
|
|
function Image(image)
|
|
if not image.src:lower():match('%.svg$') then return nil end
|
|
local name = image.src:gsub('.*/', ''):gsub('%.[Ss][Vv][Gg]$', '') .. '.pdf'
|
|
local target = build .. '/' .. name
|
|
local converted, message = pcall(pandoc.pipe, 'inkscape',
|
|
{'--export-type=pdf', '--export-filename=' .. target,
|
|
absolute(image.src)}, '')
|
|
if not converted then
|
|
error('the drawing ' .. image.src .. ' could not be converted: '
|
|
.. tostring(message))
|
|
end
|
|
image.src = target
|
|
return image
|
|
end
|