Skip to content

[Markdown Reader] Fails to parse citation immediately after an opening parenthesis #5099

Closed
@lierdakil

Description

@lierdakil

This is prompted by lierdakil/pandoc-crossref#210

Long story short, I would expect pandoc to parse (@someCitation as

[Para [Str "("
,Cite
    [Citation {
       citationId = "someCitation"
     , citationPrefix = []
     , citationSuffix = []
     , citationMode = AuthorInText
     , citationNoteNum = 0
     , citationHash = 0
    }]
    [Str "@someCitation"]
  ]
]

This is not what actually happens though:
$ pandoc -f markdown -t native <<< '(@someCitation' yields

[Para [Str "(@someCitation"]]

I'm pretty sure the culprit is line 1414 here:

citeKey :: (Stream s m Char, HasLastStrPosition st)
=> ParserT s st m (Bool, String)
citeKey = try $ do
guard =<< notAfterString
suppress_author <- option False (True <$ char '-')
char '@'
firstChar <- alphaNum <|> char '_' <|> char '*' -- @* for wildcard in nocite
let regchar = satisfy (\c -> isAlphaNum c || c == '_')
let internal p = try $ p <* lookAhead regchar
rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/") <|>
try (oneOf ":/" <* lookAhead (char '/'))
let key = firstChar:rest
return (suppress_author, key)

While on topic, this also becomes an issue at least in one other place where notAfterString is used, actually. Consider this (with smart extension):
pandoc -f markdown -t native <<< "('asd')"

[Para [Str "(\8217asd\8217)"]]

when I would expect something to the tune of

[Para [Str "(",Quoted SingleQuote [Str "asd"],Str ")"]]

instead.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions