git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Slight rewrite of enclosure/emphOrStrong code.
ee522beJohn MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+8−6
@@ -1436,9 +1436,15 @@ math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))
1436enclosure :: Char
1436enclosure :: Char
1437 -> MarkdownParser (F Inlines)
1437 -> MarkdownParser (F Inlines)
1438enclosure c = do
1438enclosure c = do
1439+ -- we can't start an enclosure with _ if after a string and
1440+ -- the intraword_underscores extension is enabled:
1441+ guardDisabled Ext_intraword_underscores
1442+ <|> guard (c == '*')
1443+ <|> (guard =<< notAfterString)
1439 cs <- many1 (char c)
1444 cs <- many1 (char c)
1440 (return (B.str cs) <>) <$> whitespace
1445 (return (B.str cs) <>) <$> whitespace
1446+ <|> do
1441− <|> case length cs of
1447+ case length cs of
1442 3 -> three c
1448 3 -> three c
1443 2 -> two c mempty
1449 2 -> two c mempty
1444 1 -> one c mempty
1450 1 -> one c mempty
@@ -1477,11 +1483,7 @@ one c prefix' = do
1477 <|> return (return (B.str [c]) <> (prefix' <> contents))
1483 <|> return (return (B.str [c]) <> (prefix' <> contents))
1478
1484
1479strongOrEmph :: MarkdownParser (F Inlines)
1485strongOrEmph :: MarkdownParser (F Inlines)
1480−strongOrEmph = enclosure '*' <|> (checkIntraword >> enclosure '_')
1486+strongOrEmph = enclosure '*' <|> enclosure '_'
1481− where checkIntraword = do
1482− exts <- getOption readerExtensions
1483− when (Ext_intraword_underscores `Set.member` exts) $ do
1484− guard =<< notAfterString
1485
1487
1486-- | Parses a list of inlines between start and end delimiters.
1488-- | Parses a list of inlines between start and end delimiters.
1487inlinesBetween :: (Show b)
1489inlinesBetween :: (Show b)