mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-27 09:55:57 +00:00
Markdown writer: don't produce redundant header identifier...
when the `gfm_auto_identifiers` extension is set. Closes #7941.
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
```
|
||||
% pandoc -f commonmark_x -t commonmark_x
|
||||
# Class setup
|
||||
^D
|
||||
# Class setup
|
||||
```
|
||||
Reference in New Issue
Block a user