add unused sources
[wix.git] / src / unused / Contex.hs
1 module Contex where
2 import Data.Array.IArray
3 import Data.Char
4 import Util
5 import Lexer
6 import IR
7 import Data.List
8 import Beautify
9
10 toContex ll = prefix ++ (concatMap tl ll) ++ suffix
11  where
12   packages                         = [ "[supp-fun]",
13                                        "[bib]",
14                                        "[href]" ]
15   prefix                           = (concatMap (\x -> "\\usemodule"++x++"\n") packages) ++
16                                      "\\setuppapersize[letter]\n" ++
17                                      "\\setuppagenumbering[location=]\n" ++
18                                      "\\setupcolors[state=start]\n" ++
19                                      --"\\setupinteraction[title={Title},author={Me},"++
20                                      --"subtitle={Deez Nutz},keywords={blargh},color=blue]\n" ++
21                                      --"\\setuppublications[database={me},numbering=yes,sort=author]\n" ++
22                                      "\\setuphead[section][style={\\ss\\bfa},\n" ++
23                                      "                     number=no,\n" ++
24                                      "                     before=\\blank\\hairline\\nowhitespace,\n" ++
25                                      "                     ]\n" ++
26                                      "\\definelayout[mypage][\n" ++
27                                      " backspace=1.75in, % the space for margin notes\n" ++
28                                      " cutspace=1.75in, % the space for right margin notes\n" ++
29                                      " width=5in" ++
30                                      "]\n" ++
31                                      "\\setuplayout[mypage]\n" ++
32                                      "\\definetypeface[myface][rm][Xserif][Warnock Pro]\n" ++
33                                      "\\definetypeface[myface][tt][Xmono][CMU Typewriter Text Regular][default]\n" ++
34                                      "\\definetypeface[myface][ss][Xsans][Myriad Pro][default]\n" ++
35                                      "\\usesymbols[uni]\n" ++
36                                      "\\definesymbol[1][{\\USymbCharZapf{39}{164}}]\n" ++
37                                      "\\setupbodyfont[myface, 11pt]\n" ++
38                                      "\\setupwhitespace[7pt]\n" ++
39                                      "\\def\\MyDroppedCaps%\n" ++
40                                      "    {\\DroppedCaps\n" ++
41                                      "        {} {Serif} {2\\baselineskip} {2pt} {1\\baselineskip} {2}}\n" ++
42                                      "\\starttext\n" ++
43                                      "\\switchtobodyfont[16pt]\\midaligned{\\ss\\bfa{Hi5 Replicated Server Infrastructure}}\\switchtobodyfont[10pt]\n"++ 
44                                      "\\midaligned{Adam Megacz}\n\n\\nowhitespace\\midaligned{\\tt{adam@megacz.com}}\n\n"++
45                                      "\\blank[1cm,force]\n" ++
46                                      "\\defineparagraphs[mypar][n=2,before={\\blank},after={\\blank}]\n"++
47                                      "\\setupparagraphs[mypar][1][width=.45\\textwidth]\n"++
48                                      "\\setupparagraphs[mypar][2][width=.55\\textwidth]\n"++
49                                      "\\startmypar"++
50                                      "\\switchtobodyfont[small]\n"
51   suffix                           = "\n\\stoptext\n"
52   addItem i                        = "\\item " ++ (striptrail $ boost 8 $ wrap $ striplead $ tl i)
53   escapify []                      = []
54   escapify ('%':t)                 = '\\':'%':(escapify t)
55   escapify ('$':t)                 = '\\':'$':(escapify t)
56   escapify (h:t)                   = h:(escapify t)
57   escapeMath s                     = s
58   tl (Special _ BulletList l)      = "\\startitemize[symbol]\n" ++ (concatMap addItem l) ++ "\\stopitemize\n"
59   tl (Special _ NumberList l)      = "\\startitemize[symbol]\n" ++ (concatMap addItem l) ++ "\\stopitemize\n"
60   tl (Special _ Section (h:t))     = "\\section{"++(tl h)++"}\n"++(concatMap tl t)
61   tl (Special _ NumberedSection (h:t)) = "\\section{"++(tl h)++"}\n"++(concatMap tl t)
62   tl (Special _ (Glyph EmDash) []) = "{\\emdash}"
63 --tl (Special _ Superscript l)     = 
64 --tl (Special _ Subscript l)       = 
65 --tl (Special _ (Image u) l)       = 
66 --tl (Special _ (Cite u) l)        = 
67   tl (Special _ BlockQuote l)      = "\n\n\\startquote\n     "++
68                                      (striptrail $ boost 4 $ wrap $ striplead $ concatMap tl l)++"\n\\stopquote\n\n"
69   tl (Special _ HorizontalRule []) = "\\\\\\rule{4in}{0.5pt}\\\\"
70   tl (Special _ Italic l)          = "{\\it{"++(concatMap tl l)++"}}"
71   tl (Special _ Bold l)            = "{\\bf{"++(concatMap tl l)++"}}"
72   tl (Special _ DropCap (h:t))     = "\\MyDroppedCaps{"++(tl h)++"}{\\sc "++(concatMap tl t)++"}"
73   tl (Special _ Typewriter l)      = "{\\tt{"++(concatMap tl l)++"}}"
74   tl (Special _ StrikeThrough l)   = "" --"\\sout{"++(concatMap tl l)++"}"
75   tl (Special _ Quotes l)          = "``"++(concatMap tl l)++"''"
76   tl (Special _ Underline l)       = "" --"\\uline{"++(concatMap tl l)++"}"
77   tl (Special _ Underline2 l)      = "" --"\\uuline{"++(concatMap tl l)++"}"
78   tl (Special _ (Math s) [])       = "\\placeformula\n$$\n" ++ (escapeMath s) ++ "\n$$\n"
79   tl (Special _ Footnote l)        = "\\footnote{"++(concatMap tl l)++"}"
80   tl (Special _ Float l)           = "" --"\n\n\\begin{wrapfigure}{r}{0.4\\textwidth} \\framebox[0.4\\textwidth]{"++
81                                      --(concatMap tl l)++"} \\label{x}\\end{wrapfigure}\n\n"
82 --tl (Special _ Figure l)          = "\\placefigure[][fig:church]{}{"++(concatMap tl l)++"}"
83   tl (Special _ Figure l)          = "\\startnarrower\n"++(concatMap tl l)++"\n\\stopnarrower\n"
84   tl (Special _ (Link u) l)        = "\\href{"++(escapify u)++"}{"++(concatMap tl l)++"}"
85   tl (Special _ (Verbatim s) [])   = "\\starttyping\n"++s++"\n\\stoptyping\n"
86 --  tl (Special _ TwoColumn l)       = "\\startcolumns[n=2]\n"++(concatMap tl l)++"\\stopcolumns"
87 --  tl (Special _ Title l)           = ""--"\\title{"++(concatMap tl l)++"}\n\\maketitle\n\n\n"
88   tl (Special _ Abstract l) =
89       "\\midaligned{\\ss\\bfa Abstract}\\par\n " ++
90       "\n\n"++(concatMap tl l)++"\\mypar" ++
91       "\\switchtobodyfont[8pt]{\\ss{\\placecontent}}\\switchtobodyfont[normal]\\stopmypar\n\n\\blank[1cm,force]"
92   tl (Special _ (Command c) l)     = "\\"++c++"["++(concatMap tl l)++"]"
93   tl (Special _ t l)               = error $ "formatting code "++(show t)++" not supported on {"++(concatMap show l)++"})"
94   tl (WS _)                        = " "
95   tl (BlankLine _)                 = "\n\n"
96   tl (Block _ l)                   = concatMap tl l
97   tl (Letter _ c)                  = escapify [c]
98   tl z                             = (show z)
99
100