diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-02-26 11:37:46 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-02-26 11:37:46 -0800 |
| commit | 7f6021d7b2b01a33701eb4e255f1bf40a71b8ef8 (patch) | |
| tree | 9fd25a93c34276f3d213f101d781a3d62f44eb27 | |
| parent | 5375bd1446fbc289e4a846963030bc679613fcc1 (diff) | |
Markdown writer: don't produce redundant header identifier...
when the `gfm_auto_identifiers` extension is set.
Closes #7941.
| -rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 4 | ||||
| -rw-r--r-- | test/command/7941.md | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 0ac058893..2d9532dd3 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -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') diff --git a/test/command/7941.md b/test/command/7941.md new file mode 100644 index 000000000..d68f04085 --- /dev/null +++ b/test/command/7941.md @@ -0,0 +1,6 @@ +``` +% pandoc -f commonmark_x -t commonmark_x +# Class setup +^D +# Class setup +``` |
