add _extensions

This commit is contained in:
2026-05-21 13:37:53 +08:00
parent 6a9a5fc90e
commit 61bd0bea2f
252 changed files with 33972 additions and 1 deletions
@@ -0,0 +1,7 @@
title: Right or Center Align Text
author: Tom Ben
version: 1.0.0
quarto-required: ">=1.5.0"
contributes:
filters:
- text-align.lua
@@ -0,0 +1,46 @@
--- Align the content of a div (right/center)
--- Copyright: © 2025Present Tom Ben
--- License: MIT License
local function wrap_with(blocks, format, start, finish)
local content = {}
table.insert(content, pandoc.RawBlock(format, start))
for _, block in ipairs(blocks) do
table.insert(content, block)
end
table.insert(content, pandoc.RawBlock(format, finish))
return content
end
local function align_block(el, align)
if FORMAT == "docx" then
if align == "right" then
el.attributes['custom-style'] = 'Right Align'
else
el.attributes['custom-style'] = 'Center Align'
end
return el
elseif FORMAT == "latex" then
if align == "right" then
return wrap_with(el.content, "latex", "\\begin{flushright}", "\\end{flushright}")
else
return wrap_with(el.content, "latex", "\\begin{center}", "\\end{center}")
end
elseif FORMAT == "typst" then
return wrap_with(el.content, "typst", "#align(" .. align .. ")[", "]")
elseif FORMAT == "html" or FORMAT == "epub" then
el.attributes['style'] = "text-align: " .. align .. ";"
return el
else
return el
end
end
function Div(el)
if el.classes:includes("right") then
return align_block(el, "right")
elseif el.classes:includes("center") then
return align_block(el, "center")
end
end