-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathnotes.lua
More file actions
54 lines (41 loc) · 1.91 KB
/
notes.lua
File metadata and controls
54 lines (41 loc) · 1.91 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
--[[
Lua filter for Easy Lecture Slides Made Difficult
Provides three additional markdown features:
- A native Div with a class of the form note<...> will be translated into a beamer \note<...>{...}. pandoc's builtin conversion of ::: notes Divs continues to work the same way.
- n@ at the start of a paragraph is converted to \footnotesize (for placing note-like text in the normal flow of text on the slide)
- a native Div with a class of the form l:ENV will be converted into a LaTeX environment \begin{ENV} ... \end{ENV} (so you can write markdown content inside a LaTeX environment...most of the time)
- a native Div with a class of the form l:ENV{PARAM} will be converted into a LaTeX environment \begin{ENV}{PARAM} ... \end{ENV}
+ no serious parsing is done of these commands: everything from the first non-alphanumeric character in ENV is simply placed after \begin{ENV}
--]]
local NN_MARK = "n@"
function Para(e)
local result = e:clone()
if e.content[1].text == NN_MARK then
result.content[1] = pandoc.RawInline("latex", "\\footnotesize")
table.insert(result.content, pandoc.RawInline("latex", "\\normalsize"))
return result
end
end
local ENV_PATTERN = "^l:(%S+)$"
function Div (e)
local cmd = e.attr.classes[1]
local _, _, env = string.find(cmd, ENV_PATTERN)
if (cmd == "note" or string.match(cmd, "^note<[0-9+,-]*>")) then
return {
pandoc.RawBlock("latex", "\\" .. cmd .. "{"),
pandoc.Div(e.content),
pandoc.RawBlock("latex", "}")
}
elseif env then
local _, _, env_name, param = string.find(env, "^(%w+)(%S*)$")
local begin = "\\begin{" .. env_name .. "}"
if param then
begin = begin .. param
end
return {
pandoc.RawBlock("latex", begin),
pandoc.Div(e.content),
pandoc.RawBlock("latex", "\\end{" .. env_name .. "}")
}
end
end