git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Slight rewrite of enclosure/emphOrStrong code.

Semantics should be the same.

commitee522be94f0691de3e81a7343c278fd4c948d20a authorJohn MacFarlane <jgm@berkeley.edu> dateThu 10 Jul 2014, 14:37 (12 years ago) parentff86702
1 file changed+8−6
src/Text/Pandoc/Readers/Markdown.hs+8−6
src/Text/Pandoc/Readers/Markdown.hs+8−6
@@ -1436,9 +1436,15 @@ math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))
14361436enclosure :: Char
14371437 -> MarkdownParser (F Inlines)
14381438enclosure 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)
14391444 cs <- many1 (char c)
14401445 (return (B.str cs) <>) <$> whitespace
1441− <|> case length cs of
1446+ <|> do
1447+ case length cs of
14421448 3 -> three c
14431449 2 -> two c mempty
14441450 1 -> one c mempty
@@ -1477,11 +1483,7 @@ one c prefix' = do
14771483 <|> return (return (B.str [c]) <> (prefix' <> contents))
14781484
14791485strongOrEmph :: MarkdownParser (F Inlines)
1480−strongOrEmph = enclosure '*' <|> (checkIntraword >> enclosure '_')
1481− where checkIntraword = do
1482− exts <- getOption readerExtensions
1483− when (Ext_intraword_underscores `Set.member` exts) $ do
1484− guard =<< notAfterString
1486+strongOrEmph = enclosure '*' <|> enclosure '_'
14851487
14861488-- | Parses a list of inlines between start and end delimiters.
14871489inlinesBetween :: (Show b)