report = env.Context('Report')
Depends(report, 'pret-lam.lua')
Depends(report, 'pret-trans.lua')
+Depends(report, 'pret-haskell.lua')
Depends(report, 'Chapters/State.tex')
Depends(report, 'Utils/Fonts.tex')
Depends(report, 'Utils/Formats.tex')
% a bunch of empty space at the start of the frame.
\framed[offset=0mm,location=middle,strut=no,align=right,frame=off]{#1}
}
+
+% Define a \strikethrough command. For some reason, this does blue
+strikethrough, sometime that still needs fixing.
+\definetextbackground
+ [strikethrough]
+ [location=text,
+ alternative=4,
+ background=,
+ frame=off]
+
\installprettytype [TRANS] [TRANS]
% Define \starttrans \stoptrans
\definetyping[trans][option=TRANS,style=normal,before=,after=]
+
+% Install the haskell pretty-printer, as defined in pret-haskell.lua.
+\installprettytype [HASKELL] [HASKELL]
+% Define \starthaskell \stophaskell
+\definetyping[haskell][option=HASKELL,before=,after=]
--- /dev/null
+-- 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: