mirror of
https://github.com/rohitg00/ai-engineering-from-scratch.git
synced 2026-10-02 01:54:39 +08:00
* 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
29 lines
712 B
Lua
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
|