mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-26 18:26:36 +00:00
Muse reader: Require space before and after '=' for code (#3758)
This commit is contained in:
committed by
John MacFarlane
parent
743419af5c
commit
f8877516e0
@@ -442,8 +442,7 @@ tableParseCaption = try $ do
|
||||
--
|
||||
|
||||
inline :: PandocMonad m => MuseParser m (F Inlines)
|
||||
inline = choice [ whitespace
|
||||
, br
|
||||
inline = choice [ br
|
||||
, footnote
|
||||
, strong
|
||||
, strongTag
|
||||
@@ -455,6 +454,7 @@ inline = choice [ whitespace
|
||||
, link
|
||||
, code
|
||||
, codeTag
|
||||
, whitespace
|
||||
, str
|
||||
, symbol
|
||||
] <?> "inline"
|
||||
@@ -535,7 +535,14 @@ strikeoutTag :: PandocMonad m => MuseParser m (F Inlines)
|
||||
strikeoutTag = inlineTag B.strikeout "del"
|
||||
|
||||
code :: PandocMonad m => MuseParser m (F Inlines)
|
||||
code = return . B.code <$> verbatimBetween '='
|
||||
code = try $ do
|
||||
pos <- getPosition
|
||||
sp <- if sourceColumn pos == 1
|
||||
then pure mempty
|
||||
else skipMany1 spaceChar >> pure B.space
|
||||
cd <- verbatimBetween '='
|
||||
notFollowedBy nonspaceChar
|
||||
return $ return (sp B.<> B.code cd)
|
||||
|
||||
codeTag :: PandocMonad m => MuseParser m (F Inlines)
|
||||
codeTag = do
|
||||
|
||||
@@ -58,6 +58,8 @@ tests =
|
||||
|
||||
, "Code" =: "=foo(bar)=" =?> para (code "foo(bar)")
|
||||
|
||||
, "Not code" =: "a=b= =c=d" =?> para (text "a=b= =c=d")
|
||||
|
||||
, "Code tag" =: "<code>foo(bar)</code>" =?> para (code "foo(bar)")
|
||||
|
||||
, testGroup "Links"
|
||||
@@ -79,6 +81,12 @@ tests =
|
||||
, "Image link with description" =:
|
||||
"[[URL:image.jpg][Image]]" =?>
|
||||
para (link "image.jpg" "" (text "Image"))
|
||||
-- Implicit links are supported in Emacs Muse, but not in Amusewiki:
|
||||
-- https://github.com/melmothx/text-amuse/issues/18
|
||||
--
|
||||
-- This test also makes sure '=' without whitespace is not treated as code markup
|
||||
, "No implicit links" =: "http://example.org/index.php?action=view&id=1"
|
||||
=?> para "http://example.org/index.php?action=view&id=1"
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user