diff options
-rw-r--r-- | src/Text/Pandoc/Extensions.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 9 | ||||
-rw-r--r-- | test/command/2397.md | 9 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs index f6db6dc0f..b543d489f 100644 --- a/src/Text/Pandoc/Extensions.hs +++ b/src/Text/Pandoc/Extensions.hs @@ -247,6 +247,7 @@ multimarkdownExtensions = extensionsFromList , Ext_definition_lists , Ext_all_symbols_escapable , Ext_implicit_header_references + , Ext_shortcut_reference_links , Ext_auto_identifiers , Ext_mmd_header_identifiers , Ext_implicit_figures diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index abaa907e0..2cd1c0d83 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -567,9 +567,14 @@ setextHeaderEnd = try $ do mmdHeaderIdentifier :: PandocMonad m => MarkdownParser m Attr mmdHeaderIdentifier = do - ident <- stripFirstAndLast . snd <$> reference + (_, raw) <- reference + let raw' = trim $ stripFirstAndLast raw + let ident = concat $ words $ map toLower raw' + let attr = (ident, [], []) + guardDisabled Ext_implicit_header_references + <|> registerImplicitHeader raw' attr skipSpaces - return (ident,[],[]) + return attr setextHeader :: PandocMonad m => MarkdownParser m (F Blocks) setextHeader = try $ do diff --git a/test/command/2397.md b/test/command/2397.md new file mode 100644 index 000000000..34d201362 --- /dev/null +++ b/test/command/2397.md @@ -0,0 +1,9 @@ +``` +% pandoc -f markdown_mmd +# Chapter 1: A long name of chapter [Chapter 1] + +See [Chapter 1]. +^D +<h1 id="chapter1">Chapter 1: A long name of chapter</h1> +<p>See <a href="#chapter1">Chapter 1</a>.</p> +``` |