-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypo.lua
More file actions
77 lines (68 loc) · 1.6 KB
/
typo.lua
File metadata and controls
77 lines (68 loc) · 1.6 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
--https://pandoc.org/lua-filters.html
-- Links ----------------------------------------------------------------------
function Link(el)
if FORMAT:match"html" then
el.target = el.target:gsub("%.md$",".html")
end
return el
end
-- Kbd ------------------------------------------------------------------------
local kbd = '<span class="nowrap">%s</span>'
function Subscript(el)
if FORMAT:match"html" then
if #el.c==1 then
return pandoc.RawInline("html",kbd:format(el.c[1].text:gsub("[^+]+","<kbd>%0</kbd>")))
end
else
--return pandoc...
end
return el
end
-- Typographics ---------------------------------------------------------------
local typo = {
["=>"]="⟹",
["->"]="⟶",
[">="]="≥",
["<="]="≤",
["~="]="≠",
["=="]="≡",
["%.%.%."]="…",
["-,"]="—,",
["-/"]="—/",
}
function Str(el)
local text = el.text
for k,v in pairs(typo) do
text = text:gsub(k,typo)
end
if text=="-" then text = "—" end
el.text = text
return el
end
--⇒
--➡
--≤
--≥
--≠
--→
--"⟶" U27F6 # LONG RIGHTWARDS ARROW
--"⟹" U27F9 # LONG RIGHTWARDS DOUBLE ARROW
-- code blocks with numbered lines --------------------------------------------
local N = 4
function CodeBlock(el)
if #el.classes==1 and select(2,el.text:gsub("\n","\n"))>=N then
table.insert(el.classes,"numberLines")
end
return el
end
-- pagetitle from header ------------------------------------------------------
local title
function Header(el)
if not title and el.level==1 then
title = pandoc.utils.stringify(el)
end
end
function Meta(meta)
meta.pagetitle = title
return meta
end