HTML writer: fix duplicate attributes on headings.
Another regression from 2.7.x. Closes #6062.
This commit is contained in:
parent
11e99409ce
commit
157936c927
2 changed files with 16 additions and 9 deletions
|
@ -29,7 +29,7 @@ module Text.Pandoc.Writers.HTML (
|
||||||
) where
|
) where
|
||||||
import Control.Monad.State.Strict
|
import Control.Monad.State.Strict
|
||||||
import Data.Char (ord)
|
import Data.Char (ord)
|
||||||
import Data.List (intercalate, intersperse, partition, delete)
|
import Data.List (intercalate, intersperse, partition, delete, (\\))
|
||||||
import Data.Maybe (fromMaybe, isJust, isNothing, mapMaybe)
|
import Data.Maybe (fromMaybe, isJust, isNothing, mapMaybe)
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
@ -664,16 +664,9 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
|
||||||
else case splitBy isPause xs of
|
else case splitBy isPause xs of
|
||||||
[] -> ([],[])
|
[] -> ([],[])
|
||||||
(z:zs) -> ([],z ++ concatMap inDiv zs)
|
(z:zs) -> ([],z ++ concatMap inDiv zs)
|
||||||
let classes' = ordNub $
|
|
||||||
["title-slide" | titleSlide] ++ ["slide" | slide] ++
|
|
||||||
["section" | (slide || writerSectionDivs opts) &&
|
|
||||||
not html5 ] ++
|
|
||||||
["level" <> tshow level | slide || writerSectionDivs opts ]
|
|
||||||
<> dclasses
|
|
||||||
let secttag = if html5
|
let secttag = if html5
|
||||||
then H5.section
|
then H5.section
|
||||||
else H.div
|
else H.div
|
||||||
let attr = (ident, classes', dkvs)
|
|
||||||
titleContents <- blockListToHtml opts titleBlocks
|
titleContents <- blockListToHtml opts titleBlocks
|
||||||
inSection <- gets stInSection
|
inSection <- gets stInSection
|
||||||
innerContents <- do
|
innerContents <- do
|
||||||
|
@ -681,6 +674,13 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
|
||||||
res <- blockListToHtml opts innerSecs
|
res <- blockListToHtml opts innerSecs
|
||||||
modify $ \st -> st{ stInSection = inSection }
|
modify $ \st -> st{ stInSection = inSection }
|
||||||
return res
|
return res
|
||||||
|
let classes' = ordNub $
|
||||||
|
["title-slide" | titleSlide] ++ ["slide" | slide] ++
|
||||||
|
["section" | (slide || writerSectionDivs opts) &&
|
||||||
|
not html5 ] ++
|
||||||
|
["level" <> tshow level | slide || writerSectionDivs opts ]
|
||||||
|
<> dclasses
|
||||||
|
let attr = (ident, classes', dkvs)
|
||||||
if titleSlide
|
if titleSlide
|
||||||
then do
|
then do
|
||||||
t <- addAttrs opts attr $
|
t <- addAttrs opts attr $
|
||||||
|
@ -704,7 +704,8 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
|
||||||
then mempty
|
then mempty
|
||||||
else innerContents <> nl opts
|
else innerContents <> nl opts
|
||||||
else do
|
else do
|
||||||
t <- addAttrs opts attr header'
|
let attr' = (ident, classes' \\ hclasses, dkvs \\ hkvs)
|
||||||
|
t <- addAttrs opts attr' header'
|
||||||
return $ t <>
|
return $ t <>
|
||||||
if null innerSecs
|
if null innerSecs
|
||||||
then mempty
|
then mempty
|
||||||
|
|
6
test/command/6062.md
Normal file
6
test/command/6062.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
```
|
||||||
|
% pandoc -f native -t html
|
||||||
|
[Header 1 ("section",["foo","unnumbered"],[("key","val")]) [Str "1"]]
|
||||||
|
^D
|
||||||
|
<h1 class="foo unnumbered" data-key="val" id="section">1</h1>
|
||||||
|
```
|
Loading…
Reference in a new issue