summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/LaTeX.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-06 09:54:58 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-06 09:54:58 +0000
commitbb8478e4e24b431ca81ee7f669d517eb11a47500 (patch)
tree3dedfbceaf88404e531b81e37f07b8f026f07ebb /src/Text/Pandoc/Writers/LaTeX.hs
parent06e6107f535ae921f4b1fec2e7de7dd98b793435 (diff)
Merged changes from 'quotes' branch since r431. Smart typography
is now handled in the Markdown and LaTeX readers, rather than in the writers. The HTML writer has been rewritten to use the prettyprinting library. git-svn-id: https://pandoc.googlecode.com/svn/trunk@436 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Writers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs43
1 files changed, 11 insertions, 32 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index e34b7b61e..aca72535d 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -84,36 +84,9 @@ escapeBar = gsub "\\|" "\\\\textbar{}"
escapeLt = gsub "<" "\\\\textless{}"
escapeGt = gsub ">" "\\\\textgreater{}"
-escapeDoubleQuotes =
- gsub "\"" "''" . -- rest are right quotes .
- gsub "``\\\\footnote" "''\\\\footnote" . -- except \footnote
- gsub "\"\\\\" "``\\\\" . -- left quote before latex command
- gsub "([[:space:]])\"" "\\1``" . -- never right quote after space
- gsub "\"('|`)([^[:punct:][:space:]])" "``{}`\\2" . -- "'word left
- gsub "\"([^[:punct:][:space:]])" "``\\1" -- "word left
-
-escapeSingleQuotes =
- gsub "`\\\\footnote" "'\\\\footnote" . -- except \footnote
- gsub "'\\\\" "`\\\\" . -- left quote before latex command
- gsub "('|`)(\"|``)" "`{}``" . -- '"word left
- gsub "([^[:punct:][:space:]])`(s|S)" "\\1'\\2" . -- catch possessives
- gsub "^'([^[:punct:][:space:]])" "`\\1" . -- 'word left
- gsub "([[:space:]])'" "\\1`" . -- never right quote after space
- gsub "([[:space:]])'([^[:punct:][:space:]])" "\\1`\\2"
- -- 'word left (leave possessives)
-
-escapeEllipses = gsub "\\.\\.\\.|\\. \\. \\." "\\ldots{}"
-
-escapeDashes = gsub "([0-9])-([0-9])" "\\1--\\2" .
- gsub " *--- *" "---" .
- gsub "([^-])--([^-])" "\\1---\\2"
-
-escapeSmart = escapeDashes . escapeSingleQuotes . escapeDoubleQuotes .
- escapeEllipses
-
--- | Escape string for LaTeX (including smart quotes, dashes, ellipses)
+-- | Escape string for LaTeX
stringToLaTeX :: String -> String
-stringToLaTeX = escapeSmart . escapeGt . escapeLt . escapeBar . escapeHat .
+stringToLaTeX = escapeGt . escapeLt . escapeBar . escapeHat .
escapeSpecial . fixBackslash . escapeBrackets .
escapeBackslash
@@ -158,9 +131,7 @@ inlineListToLaTeX :: [Block] -- ^ List of note blocks to use in resolving note
-> [Inline] -- ^ Inlines to convert
-> String
inlineListToLaTeX notes lst =
- -- first, consolidate Str and Space for more effective smartquotes:
- let lst' = consolidateList lst in
- concatMap (inlineToLaTeX notes) lst'
+ concatMap (inlineToLaTeX notes) lst
-- | Convert inline element to LaTeX
inlineToLaTeX :: [Block] -- ^ List of note blocks to use in resolving note refs
@@ -173,6 +144,14 @@ inlineToLaTeX notes (Strong lst) = "\\textbf{" ++
inlineToLaTeX notes (Code str) = "\\verb" ++ [chr] ++ stuffing ++ [chr]
where stuffing = str
chr = ((enumFromTo '!' '~') \\ stuffing) !! 0
+inlineToLaTeX notes (Quoted SingleQuote lst) =
+ "`" ++ inlineListToLaTeX notes lst ++ "'"
+inlineToLaTeX notes (Quoted DoubleQuote lst) =
+ "``" ++ inlineListToLaTeX notes lst ++ "''"
+inlineToLaTeX notes Apostrophe = "'"
+inlineToLaTeX notes EmDash = "---"
+inlineToLaTeX notes EnDash = "--"
+inlineToLaTeX notes Ellipses = "\\ldots{}"
inlineToLaTeX notes (Str str) = stringToLaTeX str
inlineToLaTeX notes (TeX str) = str
inlineToLaTeX notes (HtmlInline str) = ""