diff options
| -rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 15 | ||||
| -rw-r--r-- | test/command/8254.md | 20 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index e2e30be25..89b194767 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1931,20 +1931,23 @@ referenceLink constructor (lab, raw) = do try ((guardDisabled Ext_spaced_reference_links <|> spnl) >> reference) when (raw' == "") $ guardEnabled Ext_shortcut_reference_links let !labIsRef = raw' == "" || raw' == "[]" - let (rawprefix, rawsuffix) = + let (exclam, rawsuffix) = case T.uncons raw of - Just ('!', x) -> ("!", x) - _ -> ("", raw) + Just ('!', rest) -> (True, rest) + _ -> (False, raw) let !key = toKey $ if labIsRef then rawsuffix else raw' parsedRaw <- parseFromString' inlines raw' - fallback <- parseFromString' inlines $ dropBrackets rawsuffix + fallback <- parseFromString' inlines $ if exclam + then rawsuffix + else dropBrackets rawsuffix implicitHeaderRefs <- option False $ True <$ guardEnabled Ext_implicit_header_references let makeFallback = do parsedRaw' <- parsedRaw fallback' <- fallback - return $ rawprefix <> - B.str "[" <> fallback' <> B.str "]" <> + return $ (if exclam + then "!" <> fallback' + else B.str "[" <> fallback' <> B.str "]") <> (if sp && not (T.null raw) then B.space else mempty) <> parsedRaw' return $ do diff --git a/test/command/8254.md b/test/command/8254.md new file mode 100644 index 000000000..f2ed6dba3 --- /dev/null +++ b/test/command/8254.md @@ -0,0 +1,20 @@ +``` +% pandoc -t native +Wow![@legras_michel_2010] +^D +[ Para + [ Str "Wow!" + , Cite + [ Citation + { citationId = "legras_michel_2010" + , citationPrefix = [] + , citationSuffix = [] + , citationMode = NormalCitation + , citationNoteNum = 2 + , citationHash = 0 + } + ] + [ Str "[@legras_michel_2010]" ] + ] +] +``` |
