X-Git-Url: http://git.megacz.com/?p=wix.git;a=blobdiff_plain;f=src%2Funused%2FLatex.hs;fp=src%2Funused%2FLatex.hs;h=fbf2911bc73d7d9ed0bff438b4762399cae022ab;hp=0000000000000000000000000000000000000000;hb=c01e456a310652c5db54bd58f270b2d1f9ad6f6f;hpb=7123f2f1bd0db15a0d0a4c5d3849eae09a069a8c 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) + +