diff options
| -rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 7 | ||||
| -rw-r--r-- | test/command/9171.md | 65 |
2 files changed, 69 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 402893897..9f45154ed 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1928,6 +1928,7 @@ referenceLink constructor (lab, raw) = do <|> try ((guardDisabled Ext_spaced_reference_links <|> spnl) >> reference) when (raw' == "") $ guardEnabled Ext_shortcut_reference_links + !attr <- option nullAttr $ guardEnabled Ext_link_attributes >> attributes let !labIsRef = raw' == "" || raw' == "[]" let (exclam, rawsuffix) = case T.uncons raw of @@ -1956,11 +1957,11 @@ referenceLink constructor (lab, raw) = do then do headerKeys <- asksF stateHeaderKeys case M.lookup key headerKeys of - Just ((src, tit), _) -> constructor nullAttr src tit <$> lab + Just ((src, tit), _) -> constructor attr src tit <$> lab Nothing -> makeFallback else makeFallback - Just ((src,tit), attr) -> - constructor attr src tit <$> lab + Just ((src,tit), defattr) -> + constructor (combineAttr attr defattr) src tit <$> lab dropBrackets :: Text -> Text dropBrackets = dropRB . dropLB diff --git a/test/command/9171.md b/test/command/9171.md new file mode 100644 index 000000000..ede24e320 --- /dev/null +++ b/test/command/9171.md @@ -0,0 +1,65 @@ +``` +% pandoc -f markdown -t native +[link][link contents]{target="_blank"} +[link2](https://example.com){target="_blank"} + +[link contents]: https://example.com +^D +[ Para + [ Link + ( "" , [] , [ ( "target" , "_blank" ) ] ) + [ Str "link" ] + ( "https://example.com" , "" ) + , SoftBreak + , Link + ( "" , [] , [ ( "target" , "_blank" ) ] ) + [ Str "link2" ] + ( "https://example.com" , "" ) + ] +] + +``` + +``` +% pandoc -f markdown -t native +[link][link contents]{#id1 target="_blank"} +[link2](https://example.com){target="_blank"} + +[link contents]: https://example.com {#id2 target="_nonblank"} +^D +[ Para + [ Link + ( "id1" , [] , [ ( "target" , "_blank" ) ] ) + [ Str "link" ] + ( "https://example.com" , "" ) + , SoftBreak + , Link + ( "" , [] , [ ( "target" , "_blank" ) ] ) + [ Str "link2" ] + ( "https://example.com" , "" ) + ] +] + +``` + +``` +% pandoc -f markdown -t native +[link][link contents]{target="_blank"} +[link2](https://example.com){target="_blank"} + +[link contents]: https://example.com {.foo} +^D +[ Para + [ Link + ( "" , [ "foo" ] , [ ( "target" , "_blank" ) ] ) + [ Str "link" ] + ( "https://example.com" , "" ) + , SoftBreak + , Link + ( "" , [] , [ ( "target" , "_blank" ) ] ) + [ Str "link2" ] + ( "https://example.com" , "" ) + ] +] + +``` |
