diff options
author | ubq323 <ubq323@ubq323.website> | 2024-11-02 03:44:16 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-11-02 03:44:16 +0000 |
commit | a841432ff0be2171cea75a28035677a4cecd7186 (patch) | |
tree | 7af96e78f553eab286f2165d4ffb4ed6a6b44d3e | |
parent | 088039da231b705a59e07373bd74eb048eb86f4c (diff) |
add h offset
-rw-r--r-- | init.lua | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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 |