1.0.2: converter searches no subfolders, safer filters, forms, links and watermark
A document at the root of a checkout of 68377 folders needed 56 minutes, because the converter named the suite, the document folder and the build folder with `//` in TEXINPUTS; it now names them without recursion and the same document converts in 11.5 seconds. A file below the document no longer replaces a package of TeX Live. The security review of the pending changes found four defects, each fixed with a test proven red against the old files and green against the new ones twice: an HTML table read in an empty sandbox, so an iframe opens no address; form labels written through the LaTeX writer, so they are set as text; the form pattern scans a line once instead of quadratically; a kept build folder no longer lays the links of an earlier drawing over a new one. The form tests remove the PDF of an earlier run before each conversion. Also carried: forms out of Markdown, link colours from the company, clickable links in prose, HTML tables and SVG drawings, the watermark, and the further changes of 1.0.1 and 1.0.2 in the CHANGELOG. npm test: 1232 of 1232 checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
adc58e19d7
commit
d7aac52ac7
28 files changed
+3918
-137
No files matched your search
+40
-8
@@ -13,20 +13,47 @@
|
||||
-- `CreditCardCustomerBasicInfoSerializer` reads a boundary anyway. No hyphen is
|
||||
-- inserted: a hyphen in a path would be read as part of the path.
|
||||
--
|
||||
-- Only a span from 16 characters up is treated. The shortest one that left the
|
||||
-- type area in that document was `plim/settings.py:25` at 19 characters, and a
|
||||
-- short span finds room on the next line by itself, where breaking it would
|
||||
-- only make it harder to read.
|
||||
-- Every span that carries such a boundary is treated, however short it is. The
|
||||
-- rule used to start at 16 characters, on the reasoning that a shorter span
|
||||
-- finds room on the next line by itself; a style guide that lists the names of
|
||||
-- its convention refuted it. `--color-dark` and `--size-medium`, twelve and
|
||||
-- thirteen characters, stood in a row with one space between them, and the two
|
||||
-- lines carrying them ran 3.5 and 7.9 points past the edge while
|
||||
-- `--color-fg-error` beside them broke after a hyphen — a break in one place
|
||||
-- and none in the other, in one sentence.
|
||||
--
|
||||
-- A break that is OFFERED costs nothing: TeX takes it where a line cannot be
|
||||
-- set otherwise and leaves the span whole everywhere else, so the short span is
|
||||
-- still read in one piece on every line that has room for it.
|
||||
|
||||
local THRESHOLD = 16
|
||||
-- Where the name really begins: a name may OPEN with the characters that
|
||||
-- structure it — `--size-medium`, `.btn-primary`, `_private` — and there they
|
||||
-- structure nothing. A break between the two hyphens of a custom property, or
|
||||
-- directly behind them, leaves a line ending in `--` and a reader who copies
|
||||
-- the name with two pieces, neither of which is the name. So the run at the
|
||||
-- front belongs to the first piece, and the first break stands behind the first
|
||||
-- piece of content.
|
||||
--
|
||||
-- And the first piece is set in a box, because the break this forbids is not
|
||||
-- one this filter offers: TeX breaks after a hyphen of its own accord, in the
|
||||
-- typewriter face as anywhere else. Measured on the rendered page after the
|
||||
-- break points alone had been corrected — a line still ended in `--` with
|
||||
-- `font-size-large` on the next one. A box has no break inside it and none
|
||||
-- behind it where no space follows, which is exactly the two places.
|
||||
local function opening(text)
|
||||
local run = text:match('^[/._:%-]+')
|
||||
return run and #run or 0
|
||||
end
|
||||
|
||||
local function pieces(text)
|
||||
local parts, current = {}, ''
|
||||
local front = opening(text)
|
||||
for index = 1, #text do
|
||||
local char = text:sub(index, index)
|
||||
local following = text:sub(index + 1, index + 1)
|
||||
current = current .. char
|
||||
local structural = char:match('[/._:%-]') and following ~= ''
|
||||
local structural = index > front
|
||||
and char:match('[/._:%-]') and following ~= ''
|
||||
local camel = char:match('%l') and following:match('%u')
|
||||
if structural or camel then
|
||||
parts[#parts + 1] = current
|
||||
@@ -41,12 +68,17 @@ end
|
||||
|
||||
function Code(code)
|
||||
if not FORMAT:match('latex') then return nil end
|
||||
if #code.text < THRESHOLD then return nil end
|
||||
local parts = pieces(code.text)
|
||||
if #parts < 2 then return nil end
|
||||
local result = {}
|
||||
for index, part in ipairs(parts) do
|
||||
result[#result + 1] = pandoc.Code(part)
|
||||
if index == 1 and opening(code.text) > 0 then
|
||||
result[#result + 1] = pandoc.RawInline('latex', '\\mbox{')
|
||||
result[#result + 1] = pandoc.Code(part)
|
||||
result[#result + 1] = pandoc.RawInline('latex', '}')
|
||||
else
|
||||
result[#result + 1] = pandoc.Code(part)
|
||||
end
|
||||
if index < #parts then
|
||||
result[#result + 1] = pandoc.RawInline('latex', '\\allowbreak{}')
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user