From c01e456a310652c5db54bd58f270b2d1f9ad6f6f Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 28 Jan 2009 14:07:47 -0800 Subject: [PATCH] add unused sources darcs-hash:20090128220747-5007d-53382d938db258201d94cd0b5eb80db8c26a0b32.gz --- src/unused/Contex.hs | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ src/unused/Latex.hs | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 src/unused/Contex.hs create mode 100644 src/unused/Latex.hs diff --git a/src/unused/Contex.hs b/src/unused/Contex.hs new file mode 100644 index 0000000..68e1008 --- /dev/null +++ b/src/unused/Contex.hs @@ -0,0 +1,100 @@ +module Contex where +import Data.Array.IArray +import Data.Char +import Util +import Lexer +import IR +import Data.List +import Beautify + +toContex ll = prefix ++ (concatMap tl ll) ++ suffix + where + packages = [ "[supp-fun]", + "[bib]", + "[href]" ] + prefix = (concatMap (\x -> "\\usemodule"++x++"\n") packages) ++ + "\\setuppapersize[letter]\n" ++ + "\\setuppagenumbering[location=]\n" ++ + "\\setupcolors[state=start]\n" ++ + --"\\setupinteraction[title={Title},author={Me},"++ + --"subtitle={Deez Nutz},keywords={blargh},color=blue]\n" ++ + --"\\setuppublications[database={me},numbering=yes,sort=author]\n" ++ + "\\setuphead[section][style={\\ss\\bfa},\n" ++ + " number=no,\n" ++ + " before=\\blank\\hairline\\nowhitespace,\n" ++ + " ]\n" ++ + "\\definelayout[mypage][\n" ++ + " backspace=1.75in, % the space for margin notes\n" ++ + " cutspace=1.75in, % the space for right margin notes\n" ++ + " width=5in" ++ + "]\n" ++ + "\\setuplayout[mypage]\n" ++ + "\\definetypeface[myface][rm][Xserif][Warnock Pro]\n" ++ + "\\definetypeface[myface][tt][Xmono][CMU Typewriter Text Regular][default]\n" ++ + "\\definetypeface[myface][ss][Xsans][Myriad Pro][default]\n" ++ + "\\usesymbols[uni]\n" ++ + "\\definesymbol[1][{\\USymbCharZapf{39}{164}}]\n" ++ + "\\setupbodyfont[myface, 11pt]\n" ++ + "\\setupwhitespace[7pt]\n" ++ + "\\def\\MyDroppedCaps%\n" ++ + " {\\DroppedCaps\n" ++ + " {} {Serif} {2\\baselineskip} {2pt} {1\\baselineskip} {2}}\n" ++ + "\\starttext\n" ++ + "\\switchtobodyfont[16pt]\\midaligned{\\ss\\bfa{Hi5 Replicated Server Infrastructure}}\\switchtobodyfont[10pt]\n"++ + "\\midaligned{Adam Megacz}\n\n\\nowhitespace\\midaligned{\\tt{adam@megacz.com}}\n\n"++ + "\\blank[1cm,force]\n" ++ + "\\defineparagraphs[mypar][n=2,before={\\blank},after={\\blank}]\n"++ + "\\setupparagraphs[mypar][1][width=.45\\textwidth]\n"++ + "\\setupparagraphs[mypar][2][width=.55\\textwidth]\n"++ + "\\startmypar"++ + "\\switchtobodyfont[small]\n" + suffix = "\n\\stoptext\n" + addItem i = "\\item " ++ (striptrail $ boost 8 $ wrap $ striplead $ tl i) + escapify [] = [] + escapify ('%':t) = '\\':'%':(escapify t) + escapify ('$':t) = '\\':'$':(escapify t) + escapify (h:t) = h:(escapify t) + escapeMath s = s + tl (Special _ BulletList l) = "\\startitemize[symbol]\n" ++ (concatMap addItem l) ++ "\\stopitemize\n" + tl (Special _ NumberList l) = "\\startitemize[symbol]\n" ++ (concatMap addItem l) ++ "\\stopitemize\n" + tl (Special _ Section (h:t)) = "\\section{"++(tl h)++"}\n"++(concatMap tl t) + tl (Special _ NumberedSection (h:t)) = "\\section{"++(tl h)++"}\n"++(concatMap tl t) + tl (Special _ (Glyph EmDash) []) = "{\\emdash}" +--tl (Special _ Superscript l) = +--tl (Special _ Subscript l) = +--tl (Special _ (Image u) l) = +--tl (Special _ (Cite u) l) = + tl (Special _ BlockQuote l) = "\n\n\\startquote\n "++ + (striptrail $ boost 4 $ wrap $ striplead $ concatMap tl l)++"\n\\stopquote\n\n" + tl (Special _ HorizontalRule []) = "\\\\\\rule{4in}{0.5pt}\\\\" + tl (Special _ Italic l) = "{\\it{"++(concatMap tl l)++"}}" + tl (Special _ Bold l) = "{\\bf{"++(concatMap tl l)++"}}" + tl (Special _ DropCap (h:t)) = "\\MyDroppedCaps{"++(tl h)++"}{\\sc "++(concatMap tl t)++"}" + tl (Special _ Typewriter l) = "{\\tt{"++(concatMap tl l)++"}}" + tl (Special _ StrikeThrough l) = "" --"\\sout{"++(concatMap tl l)++"}" + tl (Special _ Quotes l) = "``"++(concatMap tl l)++"''" + tl (Special _ Underline l) = "" --"\\uline{"++(concatMap tl l)++"}" + tl (Special _ Underline2 l) = "" --"\\uuline{"++(concatMap tl l)++"}" + tl (Special _ (Math s) []) = "\\placeformula\n$$\n" ++ (escapeMath s) ++ "\n$$\n" + tl (Special _ Footnote l) = "\\footnote{"++(concatMap tl l)++"}" + tl (Special _ Float l) = "" --"\n\n\\begin{wrapfigure}{r}{0.4\\textwidth} \\framebox[0.4\\textwidth]{"++ + --(concatMap tl l)++"} \\label{x}\\end{wrapfigure}\n\n" +--tl (Special _ Figure l) = "\\placefigure[][fig:church]{}{"++(concatMap tl l)++"}" + tl (Special _ Figure l) = "\\startnarrower\n"++(concatMap tl l)++"\n\\stopnarrower\n" + tl (Special _ (Link u) l) = "\\href{"++(escapify u)++"}{"++(concatMap tl l)++"}" + tl (Special _ (Verbatim s) []) = "\\starttyping\n"++s++"\n\\stoptyping\n" +-- tl (Special _ TwoColumn l) = "\\startcolumns[n=2]\n"++(concatMap tl l)++"\\stopcolumns" +-- tl (Special _ Title l) = ""--"\\title{"++(concatMap tl l)++"}\n\\maketitle\n\n\n" + tl (Special _ Abstract l) = + "\\midaligned{\\ss\\bfa Abstract}\\par\n " ++ + "\n\n"++(concatMap tl l)++"\\mypar" ++ + "\\switchtobodyfont[8pt]{\\ss{\\placecontent}}\\switchtobodyfont[normal]\\stopmypar\n\n\\blank[1cm,force]" + tl (Special _ (Command c) l) = "\\"++c++"["++(concatMap tl l)++"]" + tl (Special _ t l) = error $ "formatting code "++(show t)++" not supported on {"++(concatMap show l)++"})" + tl (WS _) = " " + tl (BlankLine _) = "\n\n" + tl (Block _ l) = concatMap tl l + tl (Letter _ c) = escapify [c] + tl z = (show z) + + diff --git a/src/unused/Latex.hs b/src/unused/Latex.hs new file mode 100644 index 0000000..fbf2911 --- /dev/null +++ b/src/unused/Latex.hs @@ -0,0 +1,101 @@ +module Latex where +import Data.Array.IArray +import Data.Char +import Util +import Lexer +import IR +import Data.List +import Beautify + +toLatex ll = prefix ++ (concatMap tl ll) ++ suffix + where + packages = [ "{ulem}", + "{parskip}", + "{wrapfig}", + "{fancyvrb}", + "{color}", + "{palatino}", + "{parskip}", + "{multicol}", + "{sectsty}", + "[colorlinks=true,urlcolor=blue,linkcolor=blue,bookmarks=true]{hyperref}" ] + prefix = "\n\\documentclass{article}\n" ++ + "\\usepackage{mathptmx}" ++ + "\\author{BluePixel, Inc\\\\ {\\footnotesize\\bf proprietary/confidential}}" ++ + "\\usepackage{sectsty}" ++ + (concatMap (\x -> "\\usepackage"++x++"\n") packages) ++ + "\\usepackage{amstext}\n" ++ + "\\usepackage[small]{titlesec}\n" ++ + "\\titlespacing{\\section}{0pt}{\\baselineskip}{\\baselineskip}\n" ++ + "\\titlespacing{\\subsection}{0pt}{\\baselineskip}{0pt}\n" ++ + "\\renewcommand{\\ttdefault}{cmtt}\n" ++ +{- + "\\allsectionsfont{\\sffamily}\n" ++ + "\\sectionfont{\\color{black}\\leftskip=-2cm\\hrulefill\\\\"++ + "\\sffamily\\bfseries\\raggedleft\\vspace{1cm}}\n" ++ + "\\subsectionfont{\\color{black}\\dotfill\\\\\\sffamily\\raggedright\\hspace{ -4cm}}\n" ++ + "\\newdimen\\sectskip\n" ++ + "\\newdimen\\subsectskip\n" ++ + "\\newdimen\\saveskip\n" ++ + "\\saveskip=\\leftskip\n" ++ + "\\sectskip=-2cm\n" ++ + "\\subsectskip=0cm\n" ++ + "\\let\\oldsection\\section\n" ++ + "\\let\\oldsubsection\\subsection\n" ++ + "\\def\\subsection#1{\\leftskip=\\sectskip\\oldsubsection{#1}\\leftskip=0cm}\n" ++ +-} + "\\sectionfont{\\sffamily\\bfseries\\large}" ++ + "\\def\\sec#1{\\vspace{0.6cm}\\parbox{\\columnwidth}{\\hspace{-0.5cm}\\hrulefill\\vspace{-0.3cm}\\section*{\\hspace{-0.35cm}#1}}}" ++ + "\\def\\ninept{\\def\\baselinestretch{.95}\\let\\normalsize\\small\\normalsize}\n" ++ +-- "\\ninept\n" ++ + "\\sloppy\n" ++ + "\\definecolor{CodeBorder}{rgb}{0.6,0.6,0.6}\n" ++ + "\\definecolor{CodeBackground}{rgb}{0.93,0.93,0.93}\n" ++ + + "\\raggedbottom\n" ++ + "\\VerbatimFootnotes\n" ++ + "\\parindent 0pt\n" ++ + + "\\begin{document}\n" + + suffix = "\n\\end{document}\n\\end\n" + addItem i = "\\item " ++ (striptrail $ boost 8 $ wrap $ striplead $ tl i) + escapify s = s + escapeMath s = s + tl (Special _ BulletList l) = "\\begin{itemize}\n" ++ (concatMap addItem l) ++ "\\end{itemize}\n" + tl (Special _ NumberList l) = "\\begin{enumerate}\n" ++ (concatMap addItem l) ++ "\\end{enumerate}\n" + tl (Special _ Section (h:t)) = "\n\n\\hypertarget{"++(tl h)++"}{\\sec{"++(tl h)++"}}\n"++(concatMap tl t) + tl (Special _ NumberedSection (h:t)) = "\n\n\\hypertarget{"++(tl h)++"}{\\section{"++(tl h)++"}}\n"++(concatMap tl t) + tl (Special _ (Glyph EmDash) []) = "{\\emdash}" +--tl (Special _ Superscript l) = +--tl (Special _ Subscript l) = +--tl (Special _ (Image u) l) = +--tl (Special _ (Cite u) l) = + tl (Special _ BlockQuote l) = "\n\n\\begin{quote}\n "++ + (striptrail $ boost 4 $ wrap $ striplead $ concatMap tl l)++"\n\\end{quote}\n\n" + tl (Special _ HorizontalRule []) = "\\\\\\rule{4in}{0.5pt}\\\\" + tl (Special _ Italic l) = "\\textit{"++(concatMap tl l)++"}" + tl (Special _ Bold l) = "\\textbf{"++(concatMap tl l)++"}" + tl (Special _ Typewriter l) = "\\texttt{"++(concatMap tl l)++"}" + tl (Special _ StrikeThrough l) = "\\sout{"++(concatMap tl l)++"}" + tl (Special _ Quotes l) = "``"++(concatMap tl l)++"''" + tl (Special _ Underline l) = "\\uline{"++(concatMap tl l)++"}" + tl (Special _ Underline2 l) = "\\uuline{"++(concatMap tl l)++"}" + tl (Special _ (Math s) []) = "$" ++ (escapeMath s) ++ "$" + tl (Special _ Footnote l) = "\\footnote{"++(concatMap tl l)++"}" + tl (Special _ Float l) = "\n\n\\begin{wrapfigure}{r}{0.4\\textwidth} \\framebox[0.4\\textwidth]{"++ + (concatMap tl l)++"} \\label{x}\\end{wrapfigure}\n\n" + tl (Special _ (Link u) l) = "\\href{"++(escapify u)++"}{"++(concatMap tl l)++"}" + tl (Special _ (Verbatim s) []) = "\\begin{Verbatim}[gobble=4,formatcom=\\color{red},frame=single,"++ + "framesep=5mm,numbers=left,firstnumber=100]\n " ++ (boost 4 s) ++ "\\end{Verbatim}\n" +-- tl (Special _ TwoColumn l) = "\\begin{multicols}{2}\n"++(concatMap tl l)++"\n\\end{multicol}" +-- tl (Special _ Title l) = "\\title{"++(concatMap tl l)++"}\n\\maketitle\n\n\n" + tl (Special _ (Command c) l) = "\\"++c++"{"++(concatMap tl l)++"}" + tl (Special _ t l) = error $ "formatting code "++(show t)++" not supported on {"++(concatMap show l)++"})" + tl (WS _) = " " + tl (BlankLine _) = "\n\n" + tl (Block _ l) = concatMap tl l + tl (Letter _ c) = escapify [c] + tl z = (show z) + + -- 1.7.10.4