From a841432ff0be2171cea75a28035677a4cecd7186 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 2 Nov 2024 03:44:16 +0000 Subject: add h offset --- init.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'init.lua') 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 -- cgit v1.2.3