@@ -152,21 +152,13 @@ stringToLaTeX = escapeStringUsing latexEscapes
152inCmd :: String -> Doc -> Doc
152inCmd :: String -> Doc -> Doc
153inCmd cmd contents = char '\\' <> text cmd <> braces contents
153inCmd cmd contents = char '\\' <> text cmd <> braces contents
155−-- | Remove all code elements from list of inline elements
156−-- (because it's illegal to have verbatim inside some command arguments)
157−deVerb :: [Inline] -> [Inline]
159−deVerb ((Code _ str):rest) =
160− (RawInline "latex" $ "\\texttt{" ++ stringToLaTeX str ++ "}"):(deVerb rest)
161−deVerb (other:rest) = other:(deVerb rest)
163-- | Convert Pandoc block element to LaTeX.
155-- | Convert Pandoc block element to LaTeX.
164blockToLaTeX :: Block -- ^ Block to convert
156blockToLaTeX :: Block -- ^ Block to convert
165 -> State WriterState Doc
157 -> State WriterState Doc
166blockToLaTeX Null = return empty
158blockToLaTeX Null = return empty
167blockToLaTeX (Plain lst) = inlineListToLaTeX lst
159blockToLaTeX (Plain lst) = inlineListToLaTeX lst
168blockToLaTeX (Para [Image txt (src,tit)]) = do
160blockToLaTeX (Para [Image txt (src,tit)]) = do
169− capt <- inlineListToLaTeX $ deVerb txt
161+ capt <- inlineListToLaTeX txt
170 img <- inlineToLaTeX (Image txt (src,tit))
162 img <- inlineToLaTeX (Image txt (src,tit))
171 return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
163 return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
172 ("\\caption{" <> capt <> char '}') $$ "\\end{figure}" $$ blankline
164 ("\\caption{" <> capt <> char '}') $$ "\\end{figure}" $$ blankline
@@ -250,14 +242,13 @@ blockToLaTeX (DefinitionList lst) = do
250blockToLaTeX HorizontalRule = return $
242blockToLaTeX HorizontalRule = return $
251 "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline
243 "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline
252blockToLaTeX (Header level lst) = do
244blockToLaTeX (Header level lst) = do
253− let lst' = deVerb lst
254− txt <- inlineListToLaTeX lst'
245+ txt <- inlineListToLaTeX lst
255 let noNote (Note _) = Str ""
246 let noNote (Note _) = Str ""
256 noNote x = x
247 noNote x = x
257− let lstNoNotes = bottomUp noNote lst'
248+ let lstNoNotes = bottomUp noNote lst
258 -- footnotes in sections don't work unless you specify an optional
249 -- footnotes in sections don't work unless you specify an optional
259 -- argument: \section[mysec]{mysec\footnote{blah}}
250 -- argument: \section[mysec]{mysec\footnote{blah}}
260− optional <- if lstNoNotes == lst'
251+ optional <- if lstNoNotes == lst
261 then return empty
252 then return empty
263 res <- inlineListToLaTeX lstNoNotes
254 res <- inlineListToLaTeX lstNoNotes
@@ -280,7 +271,7 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
280 then return empty
271 then return empty
281 else liftM ($$ "\\ML")
272 else liftM ($$ "\\ML")
282 $ (tableRowToLaTeX True aligns widths) heads
273 $ (tableRowToLaTeX True aligns widths) heads
283− captionText <- inlineListToLaTeX $ deVerb caption
274+ captionText <- inlineListToLaTeX caption
284 let capt = if isEmpty captionText
275 let capt = if isEmpty captionText
285 then empty
276 then empty
286 else text "caption = " <> captionText <> "," <> space
277 else text "caption = " <> captionText <> "," <> space
@@ -337,7 +328,7 @@ listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
338defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
329defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
339defListItemToLaTeX (term, defs) = do
330defListItemToLaTeX (term, defs) = do
340− term' <- inlineListToLaTeX $ deVerb term
331+ term' <- inlineListToLaTeX term
341 def' <- liftM vsep $ mapM blockListToLaTeX defs
332 def' <- liftM vsep $ mapM blockListToLaTeX defs
342 return $ "\\item" <> brackets term' $$ def'
333 return $ "\\item" <> brackets term' $$ def'
@@ -355,23 +346,23 @@ isQuoted _ = False
355inlineToLaTeX :: Inline -- ^ Inline to convert
346inlineToLaTeX :: Inline -- ^ Inline to convert
356 -> State WriterState Doc
347 -> State WriterState Doc
357inlineToLaTeX (Emph lst) =
348inlineToLaTeX (Emph lst) =
358− inlineListToLaTeX (deVerb lst) >>= return . inCmd "emph"
349+ inlineListToLaTeX lst >>= return . inCmd "emph"
359inlineToLaTeX (Strong lst) =
350inlineToLaTeX (Strong lst) =
360− inlineListToLaTeX (deVerb lst) >>= return . inCmd "textbf"
351+ inlineListToLaTeX lst >>= return . inCmd "textbf"
361inlineToLaTeX (Strikeout lst) = do
352inlineToLaTeX (Strikeout lst) = do
362− contents <- inlineListToLaTeX $ deVerb lst
353+ contents <- inlineListToLaTeX lst
363 modify $ \s -> s{ stStrikeout = True }
354 modify $ \s -> s{ stStrikeout = True }
364 return $ inCmd "sout" contents
355 return $ inCmd "sout" contents
365inlineToLaTeX (Superscript lst) =
356inlineToLaTeX (Superscript lst) =
366− inlineListToLaTeX (deVerb lst) >>= return . inCmd "textsuperscript"
357+ inlineListToLaTeX lst >>= return . inCmd "textsuperscript"
367inlineToLaTeX (Subscript lst) = do
358inlineToLaTeX (Subscript lst) = do
368 modify $ \s -> s{ stSubscript = True }
359 modify $ \s -> s{ stSubscript = True }
369− contents <- inlineListToLaTeX $ deVerb lst
360+ contents <- inlineListToLaTeX lst
370 -- oddly, latex includes \textsuperscript but not \textsubscript
361 -- oddly, latex includes \textsuperscript but not \textsubscript
371 -- so we have to define it (using a different name so as not to conflict with memoir class):
362 -- so we have to define it (using a different name so as not to conflict with memoir class):
372 return $ inCmd "textsubscr" contents
363 return $ inCmd "textsubscr" contents
373inlineToLaTeX (SmallCaps lst) =
364inlineToLaTeX (SmallCaps lst) =
374− inlineListToLaTeX (deVerb lst) >>= return . inCmd "textsc"
365+ inlineListToLaTeX lst >>= return . inCmd "textsc"
375inlineToLaTeX (Cite cits lst) = do
366inlineToLaTeX (Cite cits lst) = do
376 st <- get
367 st <- get
377 let opts = stOptions st
368 let opts = stOptions st
@@ -386,7 +377,7 @@ inlineToLaTeX (Code _ str) = do
386 let chr = ((enumFromTo '!' '~') \\ str) !! 0
377 let chr = ((enumFromTo '!' '~') \\ str) !! 0
387 if writerListings (stOptions st)
378 if writerListings (stOptions st)
388 then return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr]
379 then return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr]
389− else return $ text $ "\\verb" ++ [chr] ++ str ++ [chr]
380+ else return $ text $ "\\texttt{" ++ stringToLaTeX str ++ "}"
390inlineToLaTeX (Quoted SingleQuote lst) = do
381inlineToLaTeX (Quoted SingleQuote lst) = do
391 contents <- inlineListToLaTeX lst
382 contents <- inlineListToLaTeX lst
392 let s1 = if (not (null lst)) && (isQuoted (head lst))
383 let s1 = if (not (null lst)) && (isQuoted (head lst))
@@ -422,7 +413,7 @@ inlineToLaTeX (Link txt (src, _)) =
422 [Code _ x] | x == src -> -- autolink
413 [Code _ x] | x == src -> -- autolink
423 do modify $ \s -> s{ stUrl = True }
414 do modify $ \s -> s{ stUrl = True }
424 return $ text $ "\\url{" ++ x ++ "}"
415 return $ text $ "\\url{" ++ x ++ "}"
425− _ -> do contents <- inlineListToLaTeX $ deVerb txt
416+ _ -> do contents <- inlineListToLaTeX txt
426 return $ text ("\\href{" ++ stringToLaTeX src ++ "}{") <>
417 return $ text ("\\href{" ++ stringToLaTeX src ++ "}{") <>
427 contents <> char '}'
418 contents <> char '}'
428inlineToLaTeX (Image _ (source, _)) = do
419inlineToLaTeX (Image _ (source, _)) = do