Skip to content

Commit 8d93cd7

Browse files
lierdakiljgm
authored andcommitted
Markdown writer: preserve figure attributes
0d2114e introduced a bug where Markdown writer would ignore attributes on the figure if it has class or key-value attributes set. This commit fixes that and adds a regression test. Closes #10867
1 parent 28e01fa commit 8d93cd7

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Text/Pandoc/Writers/Markdown.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@ blockToMarkdown' opts (Figure figattr capt body) = do
721721
let combinedAttr imgattr = case imgattr of
722722
("", cls, kv)
723723
| (figid, [], []) <- figattr -> Just (figid, cls, kv)
724-
| otherwise -> Just ("", cls, kv)
725724
_ -> Nothing
726725
let combinedAlt alt = case capt of
727726
Caption Nothing [] -> if null alt

test/command/10867.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```
2+
% pandoc -f native -t markdown-raw_html
3+
[ Figure
4+
( "fig:foo" , [] , [ ( "label" , "1.1" ) ] )
5+
(Caption
6+
Nothing
7+
[ Plain
8+
[ Str "Figure" , Space , Str "1.1:" , Space , Str "Figure" ]
9+
])
10+
[ Plain
11+
[ Image
12+
( "" , [] , [] )
13+
[ Str "Figure" , Space , Str "1.1:" , Space , Str "Figure" ]
14+
( "./image.png" , "" )
15+
]
16+
]
17+
]
18+
^D
19+
:::: {#fig:foo .figure label="1.1"}
20+
![Figure 1.1: Figure](./image.png)
21+
22+
::: caption
23+
Figure 1.1: Figure
24+
:::
25+
::::
26+
```

0 commit comments

Comments
 (0)