X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Freport.git;a=blobdiff_plain;f=pret-trans.lua;h=a96002f1cb894ca9db119d60a0e9dc98464511c4;hp=7f32afded167f7f07fe3f1680c7b5b313a3d78c9;hb=4beb49a9e72cb653bcbbd053e3a1dba523b53f8f;hpb=3ff8ced65f6af69db754b35b263c7d6d9f19e61f diff --git a/pret-trans.lua b/pret-trans.lua index 7f32afd..a96002f 100644 --- a/pret-trans.lua +++ b/pret-trans.lua @@ -9,7 +9,7 @@ local utf = unicode.utf8 -vis = buffers.newvisualizer("trans") +local vis = buffers.newvisualizer("trans") local commands = {} -- A command to create a horizontal rule. @@ -38,7 +38,6 @@ end -- Insert n blank lines local function blanks(n) - print("Inserting " .. n .. " blanks") for i = 1,n do buffers.visualizers.handlers.default.empty_line() end @@ -64,6 +63,9 @@ end -- Capture all lines, without generating any output function vis.begin_of_display() lines = {} + -- Let all the lambda pretty printing in this buffer use shared subscript + -- detection + buffers.visualizers.handlers.lam.begin_of_block() end function vis.begin_of_line(n) -- Don't generate output here @@ -92,8 +94,11 @@ function vis.end_of_display() break end end - print("Rule length: " .. len) - + + if not len then + error("No horizontal separator found in:\n" .. table.concat(lines, "\n")) + end + -- Split the input in three parts. Stuff before the line, stuff -- after the line, stuff to the right of the line. before, after, rights = {}, {}, {} @@ -106,7 +111,6 @@ function vis.end_of_display() if utf.match(left, "^%-%-%-*") then found_line = true else - print("Looking at " .. line .. "('" .. left .. "', '" .. right .. "')") if utf.len(left) > 0 then if not found_line then table.insert(before, left) @@ -164,6 +168,7 @@ function vis.end_of_display() -- Clean up lines = {} + buffers.visualizers.handlers.lam.end_of_block() end -- vim: set sw=4 sts=4 expandtab ai: