local utf = unicode.utf8
-vis = buffers.newvisualizer("trans")
+local vis = buffers.newvisualizer("trans")
local commands = {}
-- A command to create a horizontal rule.
-commands.rule = "\\blackrule[height=0.5pt,depth=0pt,width=.45\\textwidth]"
+commands.rule = "\\HLine[width=.40 * \\the\\textwidth]"
-- Pretty printer to use for the stuff before and after the line
commands.before_pret = "lam"
commands.after_pret = "lam"
-- Frame commands to use for the left (before + line + after) and right
-- (conditions) parts. Should include an opening {, which will be closed
-- automatically.
-commands.leftframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.5\\textwidth]{\\sans"
-commands.rightframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.5\\textwidth]{"
+commands.leftframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.48\\textwidth]{\\sans"
+commands.rightframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.48\\textwidth]{"
-- A table to keep the lines in this buffer, so we can process them all at
-- once at the 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
-- 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
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 = {}, {}, {}
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)
-- Clean up
lines = {}
+ buffers.visualizers.handlers.lam.end_of_block()
end
-- vim: set sw=4 sts=4 expandtab ai: