]> Git — Sourcephile - julm/rezine-rfcs.git/blob - styles/rfc.lua
scripts: fix rfcRevision parsing
[julm/rezine-rfcs.git] / styles / rfc.lua
1 Span = function(el)
2 color = el.attributes['c']
3 if color ~= nil then
4 el.attributes['c'] = nil
5 if FORMAT:match 'html' then
6 el.attributes['style'] = 'color: ' .. color .. ';'
7 elseif FORMAT:match 'latex' then
8 table.insert(el.content, 1, pandoc.RawInline('latex', '\\textcolor{'..color..'}{'))
9 table.insert(el.content, pandoc.RawInline('latex', '}'))
10 end
11 end
12
13 background_color = el.attributes['bc']
14 if background_color ~= nil then
15 el.attributes['bc'] = nil
16 if FORMAT:match 'html' then
17 el.attributes['style'] = 'background-color: ' .. background_color .. ';'
18 elseif FORMAT:match 'latex' then
19 table.insert(el.content, 1, pandoc.RawInline('latex', '\\colorbox{'..background_color..'}{'))
20 table.insert(el.content, pandoc.RawInline('latex', '}'))
21 end
22 end
23 return el
24 end
25
26 Link = function(el)
27 if FORMAT:match 'plain' then
28 -- Converting from Markdown to Plain Text loses any link URLs
29 -- https://github.com/jgm/pandoc/issues/2399
30 return table.insert(el.content, {pandoc.Space(), " <", pandoc.Str(el.target), pandoc.Str ">"})
31 else
32 background_color = el.attributes['bc']
33 if background_color ~= nil then
34 el.attributes['bc'] = nil
35 if FORMAT:match 'html' then
36 el.attributes['style'] = 'background-color: ' .. background_color .. ';'
37 elseif FORMAT:match 'latex' then
38 table.insert(el.content, 1, pandoc.RawInline('latex', '\\colorbox{'..background_color..'}{'))
39 table.insert(el.content, pandoc.RawInline('latex', '}'))
40 end
41 end
42 return el
43 end
44 end
45
46 Div = function(el)
47 local admonitions =
48 { important = "Important"
49 , attention = "Attention"
50 , information = "Information"
51 , problem = "Problème"
52 , solution = "Solution"
53 }
54 if admonitions[el.classes[1]] ~= nil
55 then
56 if FORMAT:match 'html' then
57 ad_type = pandoc.Div(admonitions[el.classes[1]], { class = 'admonition-type' })
58 ad_content = pandoc.Div(el.content, { class = 'admonition-content' })
59 el.content = { ad_type, ad_content }
60 table.insert(el.classes, 1, 'admonition')
61 elseif FORMAT:match 'latex' then
62 table.insert(el.content, 1, pandoc.RawBlock("latex", "\\begin{quote_" .. el.classes[1] .. "}"))
63 table.insert(el.content, pandoc.RawBlock("latex", "\\end{quote_" .. el.classes[1] .. "}"))
64 end
65 end
66 return el
67 end