aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs25
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs6
3 files changed, 21 insertions, 12 deletions
diff --git a/TODO b/TODO
index ee710a070..5264b8a67 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
# TODO
-* Fix bug in latex reader? "... gets converted the wrong way.
-
* Use XHTML library for HTML writer?
* Revisions for building with windows under cygwin:
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index f0283dd48..1f1258753 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -55,19 +55,26 @@ stringToHtml str = escapePreservingRegex stringToHtmlString (mkRegex "\"|(&[[:al
stringToSmartHtml :: String -> String
stringToSmartHtml =
let escapeDoubleQuotes =
- gsub "(\"|"|'')" "”" . -- rest are right quotes
- gsub "([[:space:]])(\"|")" "\\1“" . -- never right quo after space
- gsub "(\"|"|``)('|`|‘)([^[:punct:][:space:]])" "“‘\\3" . -- "'word left
- gsub "(\"|"|``)([^[:punct:][:space:]])" "“\\2" -- "word left
+ gsub "(\"|")" "”" . -- rest are right quotes
+ gsub "(\"|")(&r[sd]quo;)" "”\\2" . -- never left quo before right quo
+ gsub "(&l[sd]quo;)(\"|")" "\\2“" . -- never right quo after left quo
+ gsub "([ \t])(\"|")" "\\1“" . -- never right quo after space
+ gsub "(\"|")([^,.;:!?^) \t-])" "“\\2" . -- "word left
+ gsub "(\"|")('|`|‘)" "”’" . -- right if it got through last filter
+ gsub "(\"|")('|`|‘)([^,.;:!?^) \t-])" "“‘\\3" . -- "'word left
+ gsub "``" "“" .
+ gsub "''" "”"
escapeSingleQuotes =
gsub "'" "’" . -- otherwise right
- gsub "([[:space:]])'" "\\1‘" . -- never right quo after space
+ gsub "'(&r[sd]quo;)" "’\\1" . -- never left quo before right quo
+ gsub "(&l[sd]quo;)'" "\\1‘" . -- never right quo after left quo
+ gsub "([ \t])'" "\\1‘" . -- never right quo after space
gsub "`" "‘" . -- ` is left
- gsub "([^[:punct:][:space:]])'" "\\1’" . -- word' right
+ gsub "([^,.;:!?^) \t-])'" "\\1’" . -- word' right
+ gsub "^('|`)([^,.;:!?^) \t-])" "‘\\2" . -- 'word left
gsub "('|`)(\"|"|“|``)" "‘“" . -- '"word left
- gsub "^('|`)([^[:punct:][:space:]])" "‘\\2" . -- 'word left
- gsub "([^[:punct:][:space:]])'(s|S)" "\\1’\\2" . -- possessive
- gsub "([[:space:]])'([^[:punct:][:space:]])" "\\1‘\\2" . -- 'word left
+ gsub "([^,.;:!?^) \t-])'(s|S)" "\\1’\\2" . -- possessive
+ gsub "([[:space:]])'([^,.;:!?^) \t-])" "\\1‘\\2" . -- 'word left
gsub "'([0-9][0-9](s|S))" "’\\1" -- '80s - decade abbrevs.
escapeDashes = gsub " ?-- ?" "—" .
gsub " ?--- ?" "—" .
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 13eac31c2..22a96a423 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -63,12 +63,16 @@ escapeLt = gsub "<" "\\\\textless{}"
escapeGt = gsub ">" "\\\\textgreater{}"
escapeDoubleQuotes =
- gsub "\"" "''" . -- rest are right quotes
+ 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