diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-11-17 20:36:59 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-11-17 20:36:59 -0800 |
commit | bf3fea0a8cc65d140db55fc1af88be17d4df3e8b (patch) | |
tree | 74b054cb79d0e91efa0b9b115480f740b7752bde | |
parent | d464757132c028386cbeca0e0e3591dce1766bbd (diff) | |
download | pandoc-bf3fea0a8cc65d140db55fc1af88be17d4df3e8b.tar.gz |
Markdown reader: fix regression with example list references.
This affects example list references followed by dashes.
Introduced by commit b8d17f7.
Closes #6855.
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 6 | ||||
-rw-r--r-- | test/command/6855.md | 12 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 6c8442ce8..4bae8942b 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -798,7 +798,11 @@ exampleNum :: Stream s m Char => ParserT s ParserState m (ListNumberStyle, Int) exampleNum = do char '@' - lab <- T.pack <$> many (alphaNum <|> satisfy (\c -> c == '_' || c == '-')) + lab <- mconcat . map T.pack <$> + many (many1 alphaNum <|> + try (do c <- char '_' <|> char '-' + cs <- many1 alphaNum + return (c:cs))) st <- getState let num = stateNextExample st let newlabels = if T.null lab diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 02f1f212f..5888bf095 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1544,7 +1544,11 @@ exampleRef :: PandocMonad m => MarkdownParser m (F Inlines) exampleRef = try $ do guardEnabled Ext_example_lists char '@' - lab <- many1Char (alphaNum <|> oneOf "-_") + lab <- mconcat . map T.pack <$> + many (many1 alphaNum <|> + try (do c <- char '_' <|> char '-' + cs <- many1 alphaNum + return (c:cs))) return $ do st <- askF return $ case M.lookup lab (stateExamples st) of diff --git a/test/command/6855.md b/test/command/6855.md new file mode 100644 index 000000000..46f1ccf65 --- /dev/null +++ b/test/command/6855.md @@ -0,0 +1,12 @@ +``` +% pandoc -t markdown +(@a) one +(@b) two + +See (@a--@b) +^D +(1) one +(2) two + +See (1--2) +``` |