diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-07-15 16:02:46 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-07-15 16:02:46 -0700 |
commit | af445b34d8ec1a6f60cd6eb7c6964e7de450ae83 (patch) | |
tree | c53ad3de894887a4cb828748d6b34286f5fff99e /src/Text | |
parent | ec30fb37c12fc5d1a248971831414891cf6dcbe7 (diff) | |
download | pandoc-af445b34d8ec1a6f60cd6eb7c6964e7de450ae83.tar.gz |
Make markdown and github writers respect the `emoji` extension.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/CommonMark.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/CommonMark.hs b/src/Text/Pandoc/Writers/CommonMark.hs index 98c1101fa..27179496c 100644 --- a/src/Text/Pandoc/Writers/CommonMark.hs +++ b/src/Text/Pandoc/Writers/CommonMark.hs @@ -304,6 +304,11 @@ inlineToNodes opts (Math mt str) = (node (HTML_INLINE (T.pack ("\\(" ++ str ++ "\\)"))) [] :) DisplayMath -> (node (HTML_INLINE (T.pack ("\\[" ++ str ++ "\\]"))) [] :) +inlineToNodes opts (Span ("",["emoji"],kvs) [Str s]) = do + case lookup "data-emoji" kvs of + Just emojiname | isEnabled Ext_emoji opts -> + (node (TEXT (":" <> T.pack emojiname <> ":")) [] :) + _ -> (node (TEXT (T.pack s)) [] :) inlineToNodes opts (Span attr ils) = let nodes = inlinesToNodes opts ils op = tagWithAttributes opts True False "span" attr diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index dc0b154bf..c07771384 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -982,6 +982,11 @@ isRight (Left _) = False -- | Convert Pandoc inline element to markdown. inlineToMarkdown :: PandocMonad m => WriterOptions -> Inline -> MD m Doc +inlineToMarkdown opts (Span ("",["emoji"],kvs) [Str s]) = do + case lookup "data-emoji" kvs of + Just emojiname | isEnabled Ext_emoji opts -> + return $ ":" <> text emojiname <> ":" + _ -> inlineToMarkdown opts (Str s) inlineToMarkdown opts (Span attrs ils) = do plain <- asks envPlain contents <- inlineListToMarkdown opts ils |