X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Freport.git;a=blobdiff_plain;f=pret-haskell.lua;fp=pret-haskell.lua;h=483d660dd2c70c577b64ceaf2a7fef9db475f1a6;hp=0000000000000000000000000000000000000000;hb=1108517b5c84c5fc7c8aa21ac60cd33e28487519;hpb=295710e4fa6795a6d789703466dd5a7dfb488990 diff --git a/pret-haskell.lua b/pret-haskell.lua new file mode 100644 index 0000000..483d660 --- /dev/null +++ b/pret-haskell.lua @@ -0,0 +1,38 @@ +-- filename : type-haskell.lua +-- comment : Pretty printing of haskell programs. Currently, this is just +--- verbatim printing with the option of applying strikethrough +-- author : Matthijs Kooijman, Universiteit Twente, NL +-- copyright: Matthijs Kooijman +-- license : None + +local utf = unicode.utf8 + +local visualizer = buffers.newvisualizer('haskell') + +function visualizer.flush_line(str,nested) + while str ~= '' do + print("Looking at '" .. str .. "'") + if utf.match(str, '^ ') then + tex.sprint('\\obs ') + -- Eat the first character + str = utf.sub(str, 2) + else + local text, rest = utf.match(str, "^%-%-(.-)%-%-(.*)") + if text then + tex.sprint('\\strikethrough{') + -- Recursively call ourselves to handle spaces gracefully. + visualizer.flush_line(text) + tex.sprint('}') + -- Eat the processed characters + str = rest + else + -- Write the first character + tex.write(utf.sub(str, 1, 1)) + -- Eat the first character + str = utf.sub(str, 2) + end + end + end +end + +-- vim: set sw=4 sts=4 expandtab ai: