aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-10-18 12:51:34 -0700
committerJohn MacFarlane <[email protected]>2022-10-18 12:51:34 -0700
commite3fd2d5a03e601a7c2cb09059b710eb137223da5 (patch)
tree96df3064bcb04584eb1d60ea2200b4fb97bb534c
parent4103d4da825baff53016babb40f384b03052f884 (diff)
Revert "HTML reader: avoid duplicating any existing identifier..."
This reverts commit e5fbddd3b6c0c7a3b76b313edbe55242e3b138fc.
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs21
-rw-r--r--test/command/7884.md2
2 files changed, 2 insertions, 21 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index f44859ef8..9ba040a39 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -291,10 +291,7 @@ eFootnotes = try $ do
then return result
-- but there might be content other than notes, in which case
-- we want a div:
- else do
- let attr'' =toAttr attr'
- updateIdentifiers attr''
- return $ B.divWith attr'' result
+ else return $ B.divWith (toAttr attr') result
eNoteref :: PandocMonad m => TagParser m Inlines
eNoteref = try $ do
@@ -459,7 +456,6 @@ pDiv = try $ do
guardEnabled Ext_native_divs
TagOpen tag attr' <- lookAhead $ pSatisfy $ tagOpen isDivLike (const True)
let (ident, classes, kvs) = toAttr attr'
- updateIdentifiers (ident, classes, kvs)
contents <- pInTags tag block
let classes' = if tag == "section"
then "section":classes
@@ -618,7 +614,6 @@ pCodeBlock = try $ do
, let v' = if k == "class"
then fromMaybe v (T.stripPrefix "language-" v)
else v ]
- updateIdentifiers attr
contents <- manyTill pAny (pCloses "pre" <|> eof)
let rawText = T.concat $ map tagToText contents
-- drop leading newline if any
@@ -731,7 +726,6 @@ pSpanLike =
parseTag tagName = do
TagOpen _ attrs <- pSatisfy $ tagOpenLit tagName (const True)
let (ids, cs, kvs) = toAttr attrs
- updateIdentifiers (ids, cs, kvs)
content <- mconcat <$> manyTill inline (pCloses tagName <|> eof)
return $ B.spanWith (ids, tagName : cs, kvs) content
@@ -765,7 +759,6 @@ pLink = try $ do
if inFootnotes st && maybeFromAttrib "role" tag == Just "doc-backlink"
then return mempty
else do
- updateIdentifiers attr
-- check for href; if href, then a link, otherwise a span
case maybeFromAttrib "href" tag of
Nothing ->
@@ -782,7 +775,6 @@ pImage = do
let title = fromAttrib "title" tag
let alt = fromAttrib "alt" tag
let attr = toAttr $ filter (\(k,_) -> k /= "alt" && k /= "title" && k /= "src") attr'
- updateIdentifiers attr
return $ B.imageWith attr (escapeURI url) title (B.text alt)
pSvg :: PandocMonad m => TagParser m Inlines
@@ -791,7 +783,6 @@ pSvg = do
-- if raw_html enabled, parse svg tag as raw
opent@(TagOpen _ attr') <- pSatisfy (matchTagOpen "svg" [])
let (ident,cls,_) = toAttr attr'
- updateIdentifiers (ident,cls,[])
contents <- many (notFollowedBy (pCloses "svg") >> pAny)
closet <- TagClose "svg" <$ (pCloses "svg" <|> eof)
let rawText = T.strip $ renderTags' (opent : contents ++ [closet])
@@ -814,7 +805,6 @@ pCode = try $ do
code :: PandocMonad m => Text -> Attr -> TagParser m Inlines
code open attr = do
result <- mconcat <$> manyTill inline (pCloses open)
- updateIdentifiers attr
return $ formatCode attr result
-- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdo
@@ -834,7 +824,6 @@ pSpan = try $ do
guardEnabled Ext_native_spans
TagOpen _ attr' <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
let attr = toAttr attr'
- updateIdentifiers attr
contents <- pInTags "span" inline
let isSmallCaps = fontVariant == "small-caps" || "smallcaps" `elem` classes
where styleAttr = fromMaybe "" $ lookup "style" attr'
@@ -1164,11 +1153,3 @@ canonicalizeUrl url = do
return $ case (parseURIReference (T.unpack url), mbBaseHref) of
(Just rel, Just bs) -> tshow (rel `nonStrictRelativeTo` bs)
_ -> url
-
--- | Update list of identifiers in state to prevent auto_identifiers
--- from duplicating existing identifiers.
-updateIdentifiers :: PandocMonad m => Attr -> TagParser m ()
-updateIdentifiers (ident,_,_)
- | T.null ident = return ()
- | otherwise = unless (T.null ident) $
- updateState $ updateIdentifierList $ Set.insert ident
diff --git a/test/command/7884.md b/test/command/7884.md
index 3a52d97e3..be410801a 100644
--- a/test/command/7884.md
+++ b/test/command/7884.md
@@ -22,7 +22,7 @@
)
[ Header
1
- ( "chapter-1-1" , [] , [ ( "number" , "1" ) ] )
+ ( "chapter-1" , [] , [ ( "number" , "1" ) ] )
[ Str "Chapter" , Space , Str "1" ]
, Para
[ Str "Here"