@@ -65,6 +65,7 @@ data WriterState =
6565 , stHighlighting :: Bool -- true if document has highlighted code
6666 , stIncremental :: Bool -- true if beamer lists should be displayed bit by bit
6767 , stInternalLinks :: [String] -- list of internal link targets
68+ , stUsesEuro :: Bool -- true if euro symbol used
6869 }
6970
7071-- | Convert Pandoc to LaTeX.
@@ -79,7 +80,7 @@ writeLaTeX options document =
7980 stLHS = False, stBook = writerChapters options,
8081 stCsquotes = False, stHighlighting = False,
8182 stIncremental = writerIncremental options,
82− stInternalLinks = [] }
83+ stInternalLinks = [], stUsesEuro = False }
8384
8485pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
8586pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
@@ -153,6 +154,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
153154 [ ("lhs", "yes") | stLHS st ] ++
154155 [ ("graphics", "yes") | stGraphics st ] ++
155156 [ ("book-class", "yes") | stBook st] ++
157+ [ ("euro", "yes") | stUsesEuro st] ++
156158 [ ("listings", "yes") | writerListings options || stLHS st ] ++
157159 [ ("beamer", "yes") | writerBeamer options ] ++
158160 [ ("mainlang", maybe "" (reverse . takeWhile (/=',') . reverse)
@@ -173,10 +175,15 @@ elementToLaTeX opts (Sec level _ id' title' elements) = do
173175 return $ vcat (header' : innerContents)
174176
175177-- escape things as needed for LaTeX
176−stringToLaTeX :: Bool -> String -> String
177−stringToLaTeX _ [] = ""
178−stringToLaTeX isUrl (x:xs) =
179− case x of
178+stringToLaTeX :: Bool -> String -> State WriterState String
179+stringToLaTeX _ [] = return ""
180+stringToLaTeX isUrl (x:xs) = do
181+ rest <- stringToLaTeX isUrl xs
182+ when (x == '€') $
183+ modify $ \st -> st{ stUsesEuro = True }
184+ return $
185+ case x of
186+ '€' -> "\\euro{}" ++ rest
180187 '{' -> "\\{" ++ rest
181188 '}' -> "\\}" ++ rest
182189 '$' -> "\\$" ++ rest
@@ -190,7 +197,6 @@ stringToLaTeX isUrl (x:xs) =
190197 '~' | not isUrl -> "\\textasciitilde{}" ++ rest
191198 '^' -> "\\^{}" ++ rest
192199 '\\' -> "\\textbackslash{}" ++ rest
193− '€' -> "\\euro{}" ++ rest
194200 '|' -> "\\textbar{}" ++ rest
195201 '<' -> "\\textless{}" ++ rest
196202 '>' -> "\\textgreater{}" ++ rest
@@ -205,7 +211,6 @@ stringToLaTeX isUrl (x:xs) =
205211 '\x2014' -> "---" ++ rest
206212 '\x2013' -> "--" ++ rest
207213 _ -> x : rest
208− where rest = stringToLaTeX isUrl xs
209214
210215-- | Puts contents into LaTeX command.
211216inCmd :: String -> Doc -> Doc
@@ -529,8 +534,8 @@ inlineToLaTeX (Code (_,classes,_) str) = do
529534 Nothing -> rawCode
530535 Just h -> modify (\st -> st{ stHighlighting = True }) >>
531536 return (text h)
532− rawCode = return
533− $ text $ "\\texttt{" ++ stringToLaTeX False str ++ "}"
537+ rawCode = liftM (text . (\s -> "\\texttt{" ++ s ++ "}"))
538+ $ stringToLaTeX False str
534539inlineToLaTeX (Quoted SingleQuote lst) = do
535540 contents <- inlineListToLaTeX lst
536541 csquotes <- liftM stCsquotes get
@@ -557,7 +562,7 @@ inlineToLaTeX (Quoted DoubleQuote lst) = do
557562 then "\\,"
558563 else empty
559564 return $ "``" <> s1 <> contents <> s2 <> "''"
560−inlineToLaTeX (Str str) = return $ text $ stringToLaTeX False str
565+inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
561566inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$'
562567inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]"
563568inlineToLaTeX (RawInline "latex" str) = return $ text str
@@ -571,7 +576,8 @@ inlineToLaTeX (Link txt (src, _)) =
571576 do modify $ \s -> s{ stUrl = True }
572577 return $ text $ "\\url{" ++ x ++ "}"
573578 _ -> do contents <- inlineListToLaTeX txt
574− return $ text ("\\href{" ++ stringToLaTeX True src ++ "}{") <>
579+ src' <- stringToLaTeX True src
580+ return $ text ("\\href{" ++ src' ++ "}{") <>
575581 contents <> char '}'
576582inlineToLaTeX (Image _ (source, _)) = do
577583 modify $ \s -> s{ stGraphics = True }