Markdown writer: don't produce redundant header identifier...
when the `gfm_auto_identifiers` extension is set. Closes #7941.
This commit is contained in:
parent
5375bd1446
commit
7f6021d7b2
2 changed files with 9 additions and 1 deletions
|
@ -470,13 +470,15 @@ blockToMarkdown' opts (Header level attr inlines) = do
|
|||
else return empty
|
||||
variant <- asks envVariant
|
||||
-- we calculate the id that would be used by auto_identifiers
|
||||
-- or gfm_auto_identifiers
|
||||
-- so we know whether to print an explicit identifier
|
||||
ids <- gets stIds
|
||||
let autoId = uniqueIdent (writerExtensions opts) inlines ids
|
||||
modify $ \st -> st{ stIds = Set.insert autoId ids }
|
||||
let attr' = case attr of
|
||||
("",[],[]) -> empty
|
||||
(id',[],[]) | isEnabled Ext_auto_identifiers opts
|
||||
(id',[],[]) | (isEnabled Ext_auto_identifiers opts
|
||||
|| isEnabled Ext_gfm_auto_identifiers opts)
|
||||
&& id' == autoId -> empty
|
||||
(id',_,_) | isEnabled Ext_mmd_header_identifiers opts ->
|
||||
space <> brackets (literal id')
|
||||
|
|
6
test/command/7941.md
Normal file
6
test/command/7941.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
```
|
||||
% pandoc -f commonmark_x -t commonmark_x
|
||||
# Class setup
|
||||
^D
|
||||
# Class setup
|
||||
```
|
Loading…
Add table
Reference in a new issue