summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/init.lua b/init.lua
index c4358ca..21b5313 100644
--- a/init.lua
+++ b/init.lua
@@ -45,7 +45,8 @@ end
local function mode_heading(S)
local level, line = S:line():match("^#*()%s*(.*)")
- level = level - 1
+ level = level - 1 -- because () capture is offset by 1
+ level = level + (S.heading_level or 0)
S:emit(html.tag('h'..level, prose(S,line)))
end
@@ -102,11 +103,14 @@ local function split_lines(text)
end
local State = {}
-function State.new(input)
- return setmetatable({
+function State.new(input, options)
+ options = options or {}
+ local self = {
the_lines = split_lines(input),
output = "",
- }, {__index=State})
+ }
+ for k,v in pairs(options) do self[k] = v end
+ return setmetatable(self, {__index=State})
end
function State.emit(self, x)
@@ -131,8 +135,8 @@ function State.toplevel(self)
return self.output
end
-local function garkup(text)
- local S = State.new(text)
+local function garkup(...)
+ local S = State.new(...)
return S:toplevel(), S
end