From f11d0c9dc8b61cc38e138aaecb0f0094add3465a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 30 Apr 2019 22:17:31 -0700 Subject: HTML: prevent gratuitious emojification on iOS. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/Text/Pandoc/Writers/HTML.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') 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 -- cgit v1.2.3