diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-16 06:14:37 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-16 06:14:37 +0000 |
commit | 19bad8253d14b2f9f9919ddf547ce90f9b92d8b3 (patch) | |
tree | 67f8c935705dbd13026b9076e50a4b33e2f81205 /src/Text/Pandoc/Writers/HTML.hs | |
parent | fe66a90a2a88c66b1d518a932f29d9225e31ab8f (diff) | |
download | pandoc-19bad8253d14b2f9f9919ddf547ce90f9b92d8b3.tar.gz |
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
Diffstat (limited to 'src/Text/Pandoc/Writers/HTML.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 25 |
1 files changed, 16 insertions, 9 deletions
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 " ?--- ?" "—" . |