Fix typo in SConstruct file.
[matthijs/master-project/report.git] / pret-haskell.lua
1 -- filename : type-haskell.lua
2 -- comment  : Pretty printing of haskell programs. Currently, this is just
3 ---           verbatim printing with the option of applying strikethrough
4 -- author   : Matthijs Kooijman, Universiteit Twente, NL
5 -- copyright: Matthijs Kooijman
6 -- license  : None
7
8 local utf = unicode.utf8
9
10 local visualizer = buffers.newvisualizer('haskell')
11
12 function visualizer.flush_line(str,nested)
13     while str ~= '' do
14         if utf.match(str, '^ ') then 
15             tex.sprint('\\obs ')
16             -- Eat the first character
17             str = utf.sub(str, 2)
18         else
19             local text, rest = utf.match(str, "^%-%-(.-)%-%-(.*)")
20             if text then
21                 tex.sprint('\\strikethrough{')
22                 -- Recursively call ourselves to handle spaces gracefully.
23                 visualizer.flush_line(text)
24                 tex.sprint('}')
25                 -- Eat the processed characters
26                 str = rest
27             else
28                 -- Write the first character
29                 tex.write(utf.sub(str, 1, 1))
30                 -- Eat the first character
31                 str = utf.sub(str, 2)
32             end
33         end
34     end
35 end
36
37 -- vim: set sw=4 sts=4 expandtab ai: