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
8 local utf = unicode.utf8
10 local visualizer = buffers.newvisualizer('haskell')
12 -- Print a string or table of strings with the catcodes set to the default
13 -- context ones. Use this function to print a string that contains context
14 -- macro's that should be interpreted. Does not insert any automatic
16 local function ctxsprint(str)
17 tex.sprint(tex.ctxcatcodes, str)
20 -- Print a string or table of strings almost literal. Each character in the
21 -- string will be printed with the "character" catcode, causing it to show up
22 -- literal in the output. Only the space character is printed with the "space"
24 local function texwrite(str)
28 function visualizer.flush_line(str,nested)
30 if utf.match(str, '^ ') then
32 -- Eat the first character
35 local text, rest = utf.match(str, "^%-%-(.-)%-%-(.*)")
37 ctxsprint('\\strikethrough{')
38 -- Recursively call ourselves to handle spaces gracefully.
39 visualizer.flush_line(text)
41 -- Eat the processed characters
44 -- Write the first character
45 texwrite(utf.sub(str, 1, 1))
46 -- Eat the first character
53 -- vim: set sw=4 sts=4 expandtab ai: