git.iko.soy/typeable/pandoc
on master help sign in
Don't treat a citation as a reference link label.
a5cac0aJohn MacFarlane
README+3−1
@@ -2400,7 +2400,9 @@ The link consists of link text in square brackets, followed by a label in
2400square brackets. (There can be space between the two.) The link definition
2400square brackets. (There can be space between the two.) The link definition
2401consists of the bracketed label, followed by a colon and a space, followed by
2401consists of the bracketed label, followed by a colon and a space, followed by
2402the URL, and optionally (after a space) a link title either in quotes or in
2402the URL, and optionally (after a space) a link title either in quotes or in
2403−parentheses.
2403+parentheses. The label must not be parseable as a citation (assuming
2404+the `citations` extension is enabled): citations take precedence over
2405+link labels.
2404
2406
2405Here are some examples:
2407Here are some examples:
2406
2408
src/Text/Pandoc/Readers/Markdown.hs+4−3
@@ -1675,9 +1675,10 @@ referenceLink :: (String -> String -> Inlines -> Inlines)
1675 -> (F Inlines, String) -> MarkdownParser (F Inlines)
1675 -> (F Inlines, String) -> MarkdownParser (F Inlines)
1676referenceLink constructor (lab, raw) = do
1676referenceLink constructor (lab, raw) = do
1677 sp <- (True <$ lookAhead (char ' ')) <|> return False
1677 sp <- (True <$ lookAhead (char ' ')) <|> return False
1678− (ref,raw') <- try
1678+ (ref,raw') <- option (mempty, "") $
1679− (skipSpaces >> optional (newline >> skipSpaces) >> reference)
1679+ lookAhead (try (spnl >> normalCite >> return (mempty, "")))
1680− <|> return (mempty, "")
1680+ <|>
1681+ try (spnl >> reference)
1681 let labIsRef = raw' == "" || raw' == "[]"
1682 let labIsRef = raw' == "" || raw' == "[]"
1682 let key = toKey $ if labIsRef then raw else raw'
1683 let key = toKey $ if labIsRef then raw else raw'
1683 parsedRaw <- parseFromString (mconcat <$> many inline) raw'
1684 parsedRaw <- parseFromString (mconcat <$> many inline) raw'
tests/markdown-reader-more.native+2
@@ -152,6 +152,8 @@
152,Para [Link [Str "linky"] ("hi_(there_(nested))","")]
152,Para [Link [Str "linky"] ("hi_(there_(nested))","")]
153,Header 2 ("reference-link-fallbacks",[],[]) [Str "Reference",Space,Str "link",Space,Str "fallbacks"]
153,Header 2 ("reference-link-fallbacks",[],[]) [Str "Reference",Space,Str "link",Space,Str "fallbacks"]
154,Para [Str "[",Emph [Str "not",Space,Str "a",Space,Str "link"],Str "]",Space,Str "[",Emph [Str "nope"],Str "]\8230"]
154,Para [Str "[",Emph [Str "not",Space,Str "a",Space,Str "link"],Str "]",Space,Str "[",Emph [Str "nope"],Str "]\8230"]
155+,Header 2 ("reference-link-followed-by-a-citation",[],[]) [Str "Reference",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "citation"]
156+,Para [Str "MapReduce",Space,Str "is",Space,Str "a",Space,Str "paradigm",Space,Str "popularized",Space,Str "by",Space,Link [Str "Google"] ("http://google.com",""),Space,Cite [Citation {citationId = "mapreduce", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@mapreduce]"],Space,Str "as",Space,Str "its",Space,Str "most",Space,Str "vocal",Space,Str "proponent."]
155,Header 2 ("empty-reference-links",[],[]) [Str "Empty",Space,Str "reference",Space,Str "links"]
157,Header 2 ("empty-reference-links",[],[]) [Str "Empty",Space,Str "reference",Space,Str "links"]
156,Para [Str "bar"]
158,Para [Str "bar"]
157,Para [Link [Str "foo2"] ("","")]]
159,Para [Link [Str "foo2"] ("","")]]
tests/markdown-reader-more.txt+7
@@ -262,6 +262,13 @@ Empty cells
262
262
263[*not a link*] [*nope*]...
263[*not a link*] [*nope*]...
264
264
265+## Reference link followed by a citation
266+
267+MapReduce is a paradigm popularized by [Google] [@mapreduce] as its
268+most vocal proponent.
269+
270+[Google]: http://google.com
271+
265## Empty reference links
272## Empty reference links
266
273
267[foo2]:
274[foo2]: