aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-05 16:34:47 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-05 16:34:47 +0100
commite20f55618f82eb93f9ad5968e8e90b57def0d5d7 (patch)
tree3faf7c0f2212ee785155ba04ae2f22acbb662f53 /src/Text/Pandoc
parentaeb11cea4eb1d0e6f68ad71cd178cd8636dcbf5f (diff)
downloadpandoc-e20f55618f82eb93f9ad5968e8e90b57def0d5d7.tar.gz
Markdown reader: fixed internal header links.
Closes #2397. This patch also adds `shortcut_reference_links` to the list of mmd extensions.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Extensions.hs1
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs9
2 files changed, 8 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