Merge pull request #3904 from labdsf/muse-reader-code
Muse reader: debug inline code markup
This commit is contained in:
commit
4f2dd91e36
2 changed files with 38 additions and 11 deletions
|
@ -575,13 +575,6 @@ enclosedInlines :: (PandocMonad m, Show a, Show b)
|
|||
enclosedInlines start end = try $
|
||||
trimInlinesF . mconcat <$> enclosed start end inline
|
||||
|
||||
verbatimBetween :: PandocMonad m
|
||||
=> Char
|
||||
-> MuseParser m String
|
||||
verbatimBetween c = try $ do
|
||||
char c
|
||||
many1Till anyChar $ char c
|
||||
|
||||
inlineTag :: PandocMonad m
|
||||
=> (Inlines -> Inlines)
|
||||
-> String
|
||||
|
@ -617,9 +610,13 @@ code = try $ do
|
|||
sp <- if sourceColumn pos == 1
|
||||
then pure mempty
|
||||
else skipMany1 spaceChar >> pure B.space
|
||||
cd <- verbatimBetween '='
|
||||
char '='
|
||||
contents <- many1Till (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) $ char '='
|
||||
guard $ not $ null contents
|
||||
guard $ head contents `notElem` " \t\n"
|
||||
guard $ last contents `notElem` " \t\n"
|
||||
notFollowedBy nonspaceChar
|
||||
return $ return (sp B.<> B.code cd)
|
||||
return $ return (sp B.<> B.code contents)
|
||||
|
||||
codeTag :: PandocMonad m => MuseParser m (F Inlines)
|
||||
codeTag = do
|
||||
|
|
|
@ -72,9 +72,39 @@ tests =
|
|||
|
||||
, "Linebreak" =: "Line <br> break" =?> para ("Line" <> linebreak <> "break")
|
||||
|
||||
, "Code" =: "=foo(bar)=" =?> para (code "foo(bar)")
|
||||
, testGroup "Code markup"
|
||||
[ "Code" =: "=foo(bar)=" =?> para (code "foo(bar)")
|
||||
|
||||
, "Not code" =: "a=b= =c=d" =?> para (text "a=b= =c=d")
|
||||
, "Not code" =: "a=b= =c=d" =?> para (text "a=b= =c=d")
|
||||
|
||||
-- Emacs Muse 3.20 parses this as code, we follow Amusewiki
|
||||
, "Not code if closing = is detached" =: "=this is not a code =" =?> para "=this is not a code ="
|
||||
|
||||
, "Not code if opening = is detached" =: "= this is not a code=" =?> para "= this is not a code="
|
||||
|
||||
, "One character code" =: "=c=" =?> para (code "c")
|
||||
|
||||
, "Three = characters is not a code" =: "===" =?> para "==="
|
||||
|
||||
, "Multiline code markup" =:
|
||||
"foo =bar\nbaz= end of code" =?>
|
||||
para (text "foo " <> code "bar\nbaz" <> text " end of code")
|
||||
|
||||
{- Emacs Muse 3.20 has a bug: it publishes
|
||||
- <p>foo <code>bar
|
||||
-
|
||||
- baz</code> foo</p>
|
||||
- which is displayed as one paragraph by browsers.
|
||||
- We follow Amusewiki here and avoid joining paragraphs.
|
||||
-}
|
||||
, "No multiparagraph code" =:
|
||||
T.unlines [ "foo =bar"
|
||||
, ""
|
||||
, "baz= foo"
|
||||
] =?>
|
||||
para "foo =bar" <>
|
||||
para "baz= foo"
|
||||
]
|
||||
|
||||
, "Code tag" =: "<code>foo(bar)</code>" =?> para (code "foo(bar)")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue