git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1954 from mcmtroffaes/feature/citekey-firstchar-alphanum
28ca856John MacFarlane
README+1−1
@@ -2733,7 +2733,7 @@ modifying CSL styles can be found at
2733Citations go inside square brackets and are separated by semicolons.
2733Citations go inside square brackets and are separated by semicolons.
2734Each citation must have a key, composed of '@' + the citation
2734Each citation must have a key, composed of '@' + the citation
2735identifier from the database, and may optionally have a prefix,
2735identifier from the database, and may optionally have a prefix,
2736−a locator, and a suffix. The citation key must begin with a letter
2736+a locator, and a suffix. The citation key must begin with a letter, digit,
2737or `_`, and may contain alphanumerics, `_`, and internal punctuation
2737or `_`, and may contain alphanumerics, `_`, and internal punctuation
2738characters (`:.#$%&-+?<>~/`). Here are some examples:
2738characters (`:.#$%&-+?<>~/`). Here are some examples:
2739
2739
src/Text/Pandoc/Parsing.hs+1−1
@@ -1191,7 +1191,7 @@ citeKey = try $ do
1191 guard =<< notAfterString
1191 guard =<< notAfterString
1192 suppress_author <- option False (char '-' *> return True)
1192 suppress_author <- option False (char '-' *> return True)
1193 char '@'
1193 char '@'
1194− firstChar <- letter <|> char '_'
1194+ firstChar <- alphaNum <|> char '_'
1195 let regchar = satisfy (\c -> isAlphaNum c || c == '_')
1195 let regchar = satisfy (\c -> isAlphaNum c || c == '_')
1196 let internal p = try $ p <* lookAhead regchar
1196 let internal p = try $ p <* lookAhead regchar
1197 rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/")
1197 rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/")
tests/Tests/Readers/Markdown.hs+22
@@ -293,4 +293,26 @@ tests = [ testGroup "inline code"
293 , plain "b"
293 , plain "b"
294 , plain "c" <> bulletList [plain "d"] ]
294 , plain "c" <> bulletList [plain "d"] ]
295 ]
295 ]
296+ , testGroup "citations"
297+ [ "simple" =:
298+ "@item1" =?> para (cite [
299+ Citation{ citationId = "item1"
300+ , citationPrefix = []
301+ , citationSuffix = []
302+ , citationMode = AuthorInText
303+ , citationNoteNum = 0
304+ , citationHash = 0
305+ }
306+ ] "@item1")
307+ , "key starts with digit" =:
308+ "@1657:huyghens" =?> para (cite [
309+ Citation{ citationId = "1657:huyghens"
310+ , citationPrefix = []
311+ , citationSuffix = []
312+ , citationMode = AuthorInText
313+ , citationNoteNum = 0
314+ , citationHash = 0
315+ }
316+ ] "@1657:huyghens")
317+ ]
296 ]
318 ]