Files
Rohit Ghumare d18b8fe5a9 fix(book): wrap inline code and fail incomplete PDF builds (#460)
* fix(book): keep inline table code inside PDF margins

* fix(book): preserve Unicode and fail incomplete PDF builds

* fix(book): wrap inline code in PDF prose without extra symbols

* fix(book): wrap long plain-text identifiers in PDF tables

* fix(book): preserve Unicode sequences in table wrapping
2026-09-07 17:04:38 +05:30

29 lines
712 B
Lua

function Code(inline)
if FORMAT ~= "latex" then
return nil
end
local escaped = inline.text:gsub("([\\%%#{}%^ &$~_])", "\\%1")
return pandoc.RawInline("latex", "\\EscVerb{" .. escaped .. "}")
end
function Table(block)
if FORMAT ~= "latex" then
return nil
end
return block:walk({
Str = function(inline)
if #inline.text <= 20 or inline.text:find("[^ -~]") then
return nil
end
local wrapped = pandoc.List()
for character in inline.text:gmatch(".") do
if #wrapped > 0 then
wrapped:insert(pandoc.RawInline("latex", "\\allowbreak{}"))
end
wrapped:insert(pandoc.Str(character))
end
return wrapped
end,
})
end