git.iko.soy/typeable/pandoc
on master help sign in
Improvements to smart-quote regexs. Now we can better handle
19bad82fiddlosopher
@@ -1,7 +1,5 @@
1# TODO
1# TODO
2
2
3−* Fix bug in latex reader? "... gets converted the wrong way.
4−
5* Use XHTML library for HTML writer?
3* Use XHTML library for HTML writer?
6
4
7* Revisions for building with windows under cygwin:
5* Revisions for building with windows under cygwin:
src/Text/Pandoc/Writers/HTML.hs+16−9
@@ -55,19 +55,26 @@ stringToHtml str = escapePreservingRegex stringToHtmlString (mkRegex "\"|(&[[:al
55stringToSmartHtml :: String -> String
55stringToSmartHtml :: String -> String
56stringToSmartHtml =
56stringToSmartHtml =
57 let escapeDoubleQuotes =
57 let escapeDoubleQuotes =
58− gsub "(\"|"|'')" "”" . -- rest are right quotes
58+ gsub "(\"|")" "”" . -- rest are right quotes
59+ gsub "(\"|")(&r[sd]quo;)" "”\\2" . -- never left quo before right quo
60+ gsub "(&l[sd]quo;)(\"|")" "\\2“" . -- never right quo after left quo
59− gsub "([[:space:]])(\"|")" "\\1“" . -- never right quo after space
61+ gsub "([ \t])(\"|")" "\\1“" . -- never right quo after space
62+ gsub "(\"|")([^,.;:!?^) \t-])" "“\\2" . -- "word left
63+ gsub "(\"|")('|`|‘)" "”’" . -- right if it got through last filter
60− gsub "(\"|"|``)('|`|‘)([^[:punct:][:space:]])" "“‘\\3" . -- "'word left
64+ gsub "(\"|")('|`|‘)([^,.;:!?^) \t-])" "“‘\\3" . -- "'word left
61− gsub "(\"|"|``)([^[:punct:][:space:]])" "“\\2" -- "word left
65+ gsub "``" "“" .
66+ gsub "''" "”"
62 escapeSingleQuotes =
67 escapeSingleQuotes =
63 gsub "'" "’" . -- otherwise right
68 gsub "'" "’" . -- otherwise right
69+ gsub "'(&r[sd]quo;)" "’\\1" . -- never left quo before right quo
70+ gsub "(&l[sd]quo;)'" "\\1‘" . -- never right quo after left quo
64− gsub "([[:space:]])'" "\\1‘" . -- never right quo after space
71+ gsub "([ \t])'" "\\1‘" . -- never right quo after space
65 gsub "`" "‘" . -- ` is left
72 gsub "`" "‘" . -- ` is left
66− gsub "([^[:punct:][:space:]])'" "\\1’" . -- word' right
73+ gsub "([^,.;:!?^) \t-])'" "\\1’" . -- word' right
74+ gsub "^('|`)([^,.;:!?^) \t-])" "‘\\2" . -- 'word left
67 gsub "('|`)(\"|"|“|``)" "‘“" . -- '"word left
75 gsub "('|`)(\"|"|“|``)" "‘“" . -- '"word left
68− gsub "^('|`)([^[:punct:][:space:]])" "‘\\2" . -- 'word left
69− gsub "([^[:punct:][:space:]])'(s|S)" "\\1’\\2" . -- possessive
76+ gsub "([^,.;:!?^) \t-])'(s|S)" "\\1’\\2" . -- possessive
70− gsub "([[:space:]])'([^[:punct:][:space:]])" "\\1‘\\2" . -- 'word left
77+ gsub "([[:space:]])'([^,.;:!?^) \t-])" "\\1‘\\2" . -- 'word left
71 gsub "'([0-9][0-9](s|S))" "’\\1" -- '80s - decade abbrevs.
78 gsub "'([0-9][0-9](s|S))" "’\\1" -- '80s - decade abbrevs.
72 escapeDashes = gsub " ?-- ?" "—" .
79 escapeDashes = gsub " ?-- ?" "—" .
73 gsub " ?--- ?" "—" .
80 gsub " ?--- ?" "—" .
src/Text/Pandoc/Writers/LaTeX.hs+5−1
@@ -63,12 +63,16 @@ escapeLt = gsub "<" "\\\\textless{}"
63escapeGt = gsub ">" "\\\\textgreater{}"
63escapeGt = gsub ">" "\\\\textgreater{}"
64
64
65escapeDoubleQuotes =
65escapeDoubleQuotes =
66− gsub "\"" "''" . -- rest are right quotes
66+ gsub "\"" "''" . -- rest are right quotes .
67+ gsub "``\\\\footnote" "''\\\\footnote" . -- except \footnote
68+ gsub "\"\\\\" "``\\\\" . -- left quote before latex command
67 gsub "([[:space:]])\"" "\\1``" . -- never right quote after space
69 gsub "([[:space:]])\"" "\\1``" . -- never right quote after space
68 gsub "\"('|`)([^[:punct:][:space:]])" "``{}`\\2" . -- "'word left
70 gsub "\"('|`)([^[:punct:][:space:]])" "``{}`\\2" . -- "'word left
69 gsub "\"([^[:punct:][:space:]])" "``\\1" -- "word left
71 gsub "\"([^[:punct:][:space:]])" "``\\1" -- "word left
70
72
71escapeSingleQuotes =
73escapeSingleQuotes =
74+ gsub "`\\\\footnote" "'\\\\footnote" . -- except \footnote
75+ gsub "'\\\\" "`\\\\" . -- left quote before latex command
72 gsub "('|`)(\"|``)" "`{}``" . -- '"word left
76 gsub "('|`)(\"|``)" "`{}``" . -- '"word left
73 gsub "([^[:punct:][:space:]])`(s|S)" "\\1'\\2" . -- catch possessives
77 gsub "([^[:punct:][:space:]])`(s|S)" "\\1'\\2" . -- catch possessives
74 gsub "^'([^[:punct:][:space:]])" "`\\1" . -- 'word left
78 gsub "^'([^[:punct:][:space:]])" "`\\1" . -- 'word left