diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-04-30 22:17:31 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-04-30 22:32:52 -0700 |
commit | f11d0c9dc8b61cc38e138aaecb0f0094add3465a (patch) | |
tree | b9ed6e7d623f9dd4e3184299e62862716fd594db /src/Text/Pandoc | |
parent | 2b2d9baaa8341755a2c6219470639ec7c5d99551 (diff) | |
download | pandoc-f11d0c9dc8b61cc38e138aaecb0f0094add3465a.tar.gz |
HTML: prevent gratuitious emojification on iOS.
iOS chooses to render a number of Unicode entities,
including '↩', as big colorful emoji. This can be
defeated by appending Unicode
VARIATION SELECTOR-15'/'VARIATION SELECTOR-16'.
So we now append this character when escaping
strings, for both '↩' and '↔'.
If other characters prove problematic, they can
simply be added to needsVariationSelector.
Closes #5469.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 2a8835263..3cd9a0892 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -108,11 +108,20 @@ defaultWriterState = WriterState {stNotes= [], stMath = False, stQuotes = False, strToHtml :: String -> Html strToHtml ('\'':xs) = preEscapedString "\'" `mappend` strToHtml xs strToHtml ('"' :xs) = preEscapedString "\"" `mappend` strToHtml xs -strToHtml xs@(_:_) = case break (\c -> c == '\'' || c == '"') xs of +strToHtml (x:xs) | needsVariationSelector x + = preEscapedString [x, '\xFE0E'] `mappend` strToHtml xs +strToHtml xs@(_:_) = case break (\c -> c == '\'' || c == '"' || + needsVariationSelector c) xs of (_ ,[]) -> toHtml xs (ys,zs) -> toHtml ys `mappend` strToHtml zs strToHtml [] = "" +-- See #5469: this prevents iOS from substituting emojis. +needsVariationSelector :: Char -> Bool +needsVariationSelector '↩' = True +needsVariationSelector '↔' = True +needsVariationSelector _ = False + -- | Hard linebreak. nl :: WriterOptions -> Html nl opts = if writerWrapText opts == WrapNone |