mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-30 17:59:17 +08:00
Markdown reader: make attributes work with reference links.
Closes #9171.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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" , "" )
|
||||
]
|
||||
]
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user