diff options
Diffstat (limited to 'rst_context.lua')
-rw-r--r-- | rst_context.lua | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/rst_context.lua b/rst_context.lua index 15655a8..19a5167 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -57,30 +57,29 @@ function rst_context.footnote_reference (label) local tf = state.footnotes if label:match("^%d+$") then -- all digits local c = tonumber(label) - print("creating footnote nr " .. c) + --print("creating footnote nr " .. c) return [[\\footnote{\\getbuffer[__footnote_number_]].. c .."]}" elseif label == "#" then --autonumber local rc = rst_context.current_footnote_number rc = rc + 1 - --rst_context.current_footnote_number = rst_context.current_footnote_number + 1 - print("creating footnote nr " .. rc) + --print("creating footnote nr " .. rc) rst_context.current_footnote_number = rc return [[\\footnote{\\getbuffer[__footnote_number_]].. rc .."]}" elseif label:match("^#.+$") then local thelabel = label:match("^#(.+)$") - print("creating labeled footnote " .. thelabel) + --print("creating labeled footnote " .. thelabel) return [[\\footnote{\\getbuffer[__footnote_label_]].. thelabel .."]}" elseif label == "*" then local rc = rst_context.current_symbolnote_number rc = rc + 1 - print("creating symbolnote nr " .. rc) + --print("creating symbolnote nr " .. rc) rst_context.current_symbolnote_number = rc return [[\\symbolnote{\\getbuffer[__footnote_symbol_]].. rc .."]}" else -- “citation reference” for now treating them like footnotes local rc = rst_context.current_footnote_number rc = rc + 1 --rst_context.current_footnote_number = rst_context.current_footnote_number + 1 - print("creating footnote nr " .. rc) + --print("creating footnote nr " .. rc) rst_context.current_footnote_number = rc return [[\\footnote{\\getbuffer[__footnote_number_]].. rc .."]}" --return [[\\cite{]] .. label .. "}" @@ -126,7 +125,6 @@ end function rst_context.interpreted_text (...) local tab = { ... } - --print (tab, #tab, tab[1], tab[2], tab[3]) local role, str role = tab[1]:match("^:(.*):$") or tab[3]:match("^:(.*):$") str = tab[2] @@ -135,8 +133,6 @@ function rst_context.interpreted_text (...) role = "emphasis" end - --print(role, str) - return rst_context[role](str) end @@ -167,7 +163,6 @@ local removewhitespace = Cs((nowhitespace^1 + Cs(whitespace / ""))^0) function rst_context.target (tab) rst_context.addsetups("references") - --print("GOT ONE!") --local tab = { ... } local refs = rst_context.collected_references local target = tab[#tab] -- Ct + C could be clearer but who cares @@ -185,7 +180,6 @@ function rst_context.target (tab) --if removewhitespace:match(target) == "" then if target == "" then -- links here for _, id in next, tab do - print(id) insert = insert .. "\n\\reference[__target_" .. id .. "]{}" end else @@ -474,9 +468,7 @@ function rst_context.paragraph (data) if not data then return "" elseif type(data) == "table" then - print(data,#data,data[1]) str = #data > 1 and helpers.string.wrapat(inline_parser:match(table.concat(data, " ")), 65) or data[1] - print(str) else str = data end @@ -653,7 +645,6 @@ function rst_context.deflist (list) \\startRSTdefinitionlist ]] for nd, item in ipairs(list) do - print(#item) local term = item[1] local nc = 2 local tmp = [[ @@ -719,12 +710,10 @@ function rst_context.field (tab) end function rst_context.line_comment (str) - print(">>"..str.."<<") return "% " .. str end function rst_context.block_comment (str) - print(">>"..str.."<<") return string.format([[ \iffalse @@ -758,13 +747,20 @@ function rst_context.option_item (tab) end function rst_context.test(str) - print("This:>>"..str.."<<") return ":" end function rst_context.literal_block (str, included) local indent = P" "^1 - local stripme = indent:match(str) or 0 + --local stripme = indent:match(str) or 0 + local stripme = #str + for line in str:gmatch("[^\n]+") do + -- setting to the lowest indend of all lines + local idt = indent:match(line) + if line and idt then + stripme = idt < stripme and idt or stripme + end + end local strip = P{ [1] = "strip", @@ -1052,7 +1048,6 @@ end function rst_context.substitution_definition (subtext, directive, data) data = table.concat(data, "\n") - print(subtext,directive,data) local rs = rst_context.substitutions rs[subtext] = { directive = directive, data = data } return "" @@ -1101,7 +1096,6 @@ function optional_setups.references () local refs = rst_context.collected_references local function resolve_indirect (r) if r and r:match(".*_$") then -- pointing elsewhere - --print(">>"..r.."<<",">>"..r:match("^`?([^`]*)`?_$").."<<", refs[r:match("^`?([^`]*)`?_$")]) return resolve_indirect (refs[r:match("^`?([^`]*)`?_$")]) or "need another run!" -- TODO multiple runs && data collection end return r |