Spaces:
Sleeping
Sleeping
File size: 1,171 Bytes
83491c8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | -- assets/table-header-bold.lua
local function bold_blocks(blocks)
local out = {}
for _, blk in ipairs(blocks) do
if blk.t == "Plain" then
table.insert(out, pandoc.Plain({ pandoc.Strong(blk.content) }))
elseif blk.t == "Para" then
table.insert(out, pandoc.Para({ pandoc.Strong(blk.content) }))
else
table.insert(out, blk)
end
end
return out
end
function Table(tbl)
-- 1) Bold header
if tbl.head and tbl.head.rows then
for _, row in ipairs(tbl.head.rows) do
for _, cell in ipairs(row.cells or {}) do
cell.contents = bold_blocks(cell.contents or {})
end
end
end
-- 2) Bold các ô bắt đầu bằng "Chủ đề"
if tbl.bodies then
for _, body in ipairs(tbl.bodies) do
if body.body and body.body.rows then
for _, row in ipairs(body.body.rows) do
for _, cell in ipairs(row.cells or {}) do
local txt = pandoc.utils.stringify(cell)
if txt:match("^[%s]*[Cc][Hh][Uu][^ ]*[ ]*[Dd][Ee][Ee]") then
cell.contents = bold_blocks(cell.contents or {})
end
end
end
end
end
end
return tbl
end
|