Muse reader: add inline <literal> support

This commit is contained in:
Alexander Krotov 2017-11-21 19:19:49 +03:00
parent 1c85a158f3
commit 6c17117ef2
2 changed files with 20 additions and 0 deletions

View file

@ -577,6 +577,7 @@ inlineList = [ endline
, link
, code
, codeTag
, inlineLiteralTag
, whitespace
, str
, symbol
@ -693,6 +694,16 @@ codeTag = do
(attrs, content) <- parseHtmlContentWithAttrs "code" anyChar
return $ return $ B.codeWith attrs $ fromEntities content
inlineLiteralTag :: PandocMonad m => MuseParser m (F Inlines)
inlineLiteralTag = do
guardDisabled Ext_amuse -- Text::Amuse does not support <literal>
(attrs, content) <- parseHtmlContentWithAttrs "literal" anyChar
return $ return $ rawInline (attrs, content)
where
-- FIXME: Emacs Muse inserts <literal> without style into all output formats, but we assume HTML
format (_, _, kvs) = fromMaybe "html" $ lookup "style" kvs
rawInline (attrs, content) = B.rawInline (format attrs) $ fromEntities content
str :: PandocMonad m => MuseParser m (F Inlines)
str = fmap (return . B.str) (many1 alphaNum <|> count 1 characterReference)

View file

@ -149,6 +149,15 @@ tests =
, "No implicit links" =: "http://example.org/index.php?action=view&id=1"
=?> para "http://example.org/index.php?action=view&id=1"
]
, testGroup "Literal"
[ test emacsMuse "Inline literal"
("Foo<literal style=\"html\">lit</literal>bar" =?>
para (text "Foo" <> rawInline "html" "lit" <> text "bar"))
, "No literal in Text::Amuse" =:
"Foo<literal style=\"html\">lit</literal>bar" =?>
para "Foo<literal style=\"html\">lit</literal>bar"
]
]
, testGroup "Blocks"