diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-11-11 13:27:25 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-11-11 13:46:23 -0800 |
commit | a36d202e862f3fe0652e4f46cf7713120f50be28 (patch) | |
tree | 57b26749c5aff5e02e379fd5ae9824e513677fd4 /src/Text/Pandoc/Readers/Docx.hs | |
parent | ca17ae52465e0194b97d38b9a065a8186cb23a6d (diff) | |
download | pandoc-a36d202e862f3fe0652e4f46cf7713120f50be28.tar.gz |
Text.Pandoc.Shared: add parameter to uniqueIdent, inlineListToIdentifier.
The parameter is Extensions. This allows these functions to
be sensitive to the settings of `Ext_gfm_auto_identifiers` and
`Ext_ascii_identifiers`.
This allows us to use `uniqueIdent` in the CommonMark reader,
replacing some custom code.
It also means that `gfm_auto_identifiers` can now be used
in all formats.
Semantically, `gfm_auto_identifiers` is now a modifier of
`auto_identifiers`; for identifiers to be set, `auto_identifiers`
must be turned on, and then the type of identifier produced
depends on `gfm_auto_identifiers` and `ascii_identifiers` are set.
Closes #5057.
Diffstat (limited to 'src/Text/Pandoc/Readers/Docx.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index ca9f8c8dd..621239bc7 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -442,9 +442,11 @@ parPartToInlines' (BookMark _ anchor) = (modify $ \s -> s { docxAnchorMap = M.insert anchor prevAnchor anchorMap}) return mempty Nothing -> do + exts <- readerExtensions <$> asks docxOptions let newAnchor = if not inHdrBool && anchor `elem` M.elems anchorMap - then uniqueIdent [Str anchor] (Set.fromList $ M.elems anchorMap) + then uniqueIdent exts [Str anchor] + (Set.fromList $ M.elems anchorMap) else anchor unless inHdrBool (modify $ \s -> s { docxAnchorMap = M.insert anchor newAnchor anchorMap}) @@ -487,8 +489,9 @@ makeHeaderAnchor' (Header n (ident, classes, kvs) ils) | (c:_) <- filter isAnchorSpan ils , (Span (anchIdent, ["anchor"], _) cIls) <- c = do hdrIDMap <- gets docxAnchorMap + exts <- readerExtensions <$> asks docxOptions let newIdent = if null ident - then uniqueIdent ils (Set.fromList $ M.elems hdrIDMap) + then uniqueIdent exts ils (Set.fromList $ M.elems hdrIDMap) else ident newIls = concatMap f ils where f il | il == c = cIls | otherwise = [il] @@ -499,8 +502,9 @@ makeHeaderAnchor' (Header n (ident, classes, kvs) ils) makeHeaderAnchor' (Header n (ident, classes, kvs) ils) = do hdrIDMap <- gets docxAnchorMap + exts <- readerExtensions <$> asks docxOptions let newIdent = if null ident - then uniqueIdent ils (Set.fromList $ M.elems hdrIDMap) + then uniqueIdent exts ils (Set.fromList $ M.elems hdrIDMap) else ident modify $ \s -> s {docxAnchorMap = M.insert newIdent newIdent hdrIDMap} return $ Header n (newIdent, classes, kvs) ils |