41 lines
1.0 KiB
Lua
41 lines
1.0 KiB
Lua
-- list of supported environment classes in package awesomebox
|
|
local default_env_available = { 'note', 'tip', 'warning', 'caution', 'important' }
|
|
-- list of mappings: environment that are mapped to a supported env in awesomebox
|
|
local default_env_mapping = {
|
|
['info'] = 'note', -- example: the div with class .info will be transformed to tip
|
|
['warning'] = 'caution',
|
|
['danger'] = 'important',
|
|
}
|
|
|
|
|
|
local function get_box(classes)
|
|
for l,c in ipairs(classes) do
|
|
for k,v in ipairs(default_env_available) do
|
|
if c:match(v) then
|
|
return v
|
|
end
|
|
end
|
|
for k,v in pairs(default_env_mapping) do
|
|
if c:match(k) then
|
|
return v
|
|
end
|
|
end
|
|
end
|
|
|
|
return nil
|
|
end
|
|
|
|
if FORMAT:match('latex') then
|
|
function Div(div)
|
|
box = get_box(div.classes)
|
|
if box ~= nil then
|
|
blockname = box .. 'block'
|
|
return {
|
|
pandoc.RawBlock('latex', '\\begin{' .. blockname .. '}'),
|
|
div,
|
|
pandoc.RawBlock('latex', '\\end{' .. blockname .. '}'),
|
|
}
|
|
end
|
|
end
|
|
end
|