Use local variables for storing visualizer dicts.
[matthijs/master-project/report.git] / pret-trans.lua
index 7f32afded167f7f07fe3f1680c7b5b313a3d78c9..6ad51b74574768036e04200f2be9b0734f60a1b2 100644 (file)
@@ -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
@@ -92,8 +91,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 +108,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)