git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1954 from mcmtroffaes/feature/citekey-firstchar-alphanum

Allow digit as first character of a citation key.

commit28ca8566ab72e135d559e457e28d3f3f306a7b0e authorJohn MacFarlane <jgm@berkeley.edu> dateFri 17 Apr 2015, 19:10 (12 years ago) parent44fcc5fdccd408
3 files changed+24−2
README+1−1 src/Text/Pandoc/Parsing.hs+1−1 tests/Tests/Readers/Markdown.hs+22
README+1−1
@@ -2733,7 +2733,7 @@ modifying CSL styles can be found at
27332733Citations go inside square brackets and are separated by semicolons.
27342734Each citation must have a key, composed of '@' + the citation
27352735identifier 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,
27372737or `_`, and may contain alphanumerics, `_`, and internal punctuation
27382738characters (`:.#$%&-+?<>~/`). Here are some examples:
27392739
src/Text/Pandoc/Parsing.hs+1−1
@@ -1191,7 +1191,7 @@ citeKey = try $ do
11911191 guard =<< notAfterString
11921192 suppress_author <- option False (char '-' *> return True)
11931193 char '@'
1194− firstChar <- letter <|> char '_'
1194+ firstChar <- alphaNum <|> char '_'
11951195 let regchar = satisfy (\c -> isAlphaNum c || c == '_')
11961196 let internal p = try $ p <* lookAhead regchar
11971197 rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/")
tests/Tests/Readers/Markdown.hs+22
@@ -293,4 +293,26 @@ tests = [ testGroup "inline code"
293293 , plain "b"
294294 , plain "c" <> bulletList [plain "d"] ]
295295 ]
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+ ]
296318 ]