git.iko.soy/typeable/pandoc
on master help sign in
Improvements to smart-quote regexs. Now we can better handle

cases where latex commands or HTML entity references appear after quotes. git-svn-id: https://pandoc.googlecode.com/svn/trunk@202 788f1e2b-df1e-0410-8736-df70ead52e1b

commit19bad8253d14b2f9f9919ddf547ce90f9b92d8b3 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 16 Dec 2006, 06:14 (20 years ago) parentfe66a90
3 files changed+21−12
TODO−2 src/Text/Pandoc/Writers/HTML.hs+16−9 src/Text/Pandoc/Writers/LaTeX.hs+5−1
TODO−2
@@ -1,7 +1,5 @@
11# TODO
22
3−* Fix bug in latex reader? "... gets converted the wrong way.
4−
53* Use XHTML library for HTML writer?
64
75* 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
5555stringToSmartHtml :: String -> String
5656stringToSmartHtml =
5757 let escapeDoubleQuotes =
58− gsub "(\"|&quot;|'')" "&rdquo;" . -- rest are right quotes
59− gsub "([[:space:]])(\"|&quot;)" "\\1&ldquo;" . -- never right quo after space
60− gsub "(\"|&quot;|``)('|`|&lsquo;)([^[:punct:][:space:]])" "&ldquo;&lsquo;\\3" . -- "'word left
61− gsub "(\"|&quot;|``)([^[:punct:][:space:]])" "&ldquo;\\2" -- "word left
58+ gsub "(\"|&quot;)" "&rdquo;" . -- rest are right quotes
59+ gsub "(\"|&quot;)(&r[sd]quo;)" "&rdquo;\\2" . -- never left quo before right quo
60+ gsub "(&l[sd]quo;)(\"|&quot;)" "\\2&ldquo;" . -- never right quo after left quo
61+ gsub "([ \t])(\"|&quot;)" "\\1&ldquo;" . -- never right quo after space
62+ gsub "(\"|&quot;)([^,.;:!?^) \t-])" "&ldquo;\\2" . -- "word left
63+ gsub "(\"|&quot;)('|`|&lsquo;)" "&rdquo;&rsquo;" . -- right if it got through last filter
64+ gsub "(\"|&quot;)('|`|&lsquo;)([^,.;:!?^) \t-])" "&ldquo;&lsquo;\\3" . -- "'word left
65+ gsub "``" "&ldquo;" .
66+ gsub "''" "&rdquo;"
6267 escapeSingleQuotes =
6368 gsub "'" "&rsquo;" . -- otherwise right
64− gsub "([[:space:]])'" "\\1&lsquo;" . -- never right quo after space
69+ gsub "'(&r[sd]quo;)" "&rsquo;\\1" . -- never left quo before right quo
70+ gsub "(&l[sd]quo;)'" "\\1&lsquo;" . -- never right quo after left quo
71+ gsub "([ \t])'" "\\1&lsquo;" . -- never right quo after space
6572 gsub "`" "&lsquo;" . -- ` is left
66− gsub "([^[:punct:][:space:]])'" "\\1&rsquo;" . -- word' right
73+ gsub "([^,.;:!?^) \t-])'" "\\1&rsquo;" . -- word' right
74+ gsub "^('|`)([^,.;:!?^) \t-])" "&lsquo;\\2" . -- 'word left
6775 gsub "('|`)(\"|&quot;|&ldquo;|``)" "&lsquo;&ldquo;" . -- '"word left
68− gsub "^('|`)([^[:punct:][:space:]])" "&lsquo;\\2" . -- 'word left
69− gsub "([^[:punct:][:space:]])'(s|S)" "\\1&rsquo;\\2" . -- possessive
70− gsub "([[:space:]])'([^[:punct:][:space:]])" "\\1&lsquo;\\2" . -- 'word left
76+ gsub "([^,.;:!?^) \t-])'(s|S)" "\\1&rsquo;\\2" . -- possessive
77+ gsub "([[:space:]])'([^,.;:!?^) \t-])" "\\1&lsquo;\\2" . -- 'word left
7178 gsub "'([0-9][0-9](s|S))" "&rsquo;\\1" -- '80s - decade abbrevs.
7279 escapeDashes = gsub " ?-- ?" "&mdash;" .
7380 gsub " ?--- ?" "&mdash;" .
src/Text/Pandoc/Writers/LaTeX.hs+5−1
@@ -63,12 +63,16 @@ escapeLt = gsub "<" "\\\\textless{}"
6363escapeGt = gsub ">" "\\\\textgreater{}"
6464
6565escapeDoubleQuotes =
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
6769 gsub "([[:space:]])\"" "\\1``" . -- never right quote after space
6870 gsub "\"('|`)([^[:punct:][:space:]])" "``{}`\\2" . -- "'word left
6971 gsub "\"([^[:punct:][:space:]])" "``\\1" -- "word left
7072
7173escapeSingleQuotes =
74+ gsub "`\\\\footnote" "'\\\\footnote" . -- except \footnote
75+ gsub "'\\\\" "`\\\\" . -- left quote before latex command
7276 gsub "('|`)(\"|``)" "`{}``" . -- '"word left
7377 gsub "([^[:punct:][:space:]])`(s|S)" "\\1'\\2" . -- catch possessives
7478 gsub "^'([^[:punct:][:space:]])" "`\\1" . -- 'word left