diff options
| author | Benjamin Esham <benjamin@esham.io> | 2023-08-31 23:30:25 -0400 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-09-01 11:42:48 -0700 |
| commit | 9190b19fc7cfb1037fc35fa564142122eae985e6 (patch) | |
| tree | 0c81bd0706a5da68aa57d087306cb989544982eb | |
| parent | 5fe3396a221b34145c56ccfae39ab947fb407817 (diff) | |
HTML writer: use the ID prefix in the ID for the footnotes section.
In general, the ID prefix makes it possible to combine multiple pieces
of Pandoc-generated HTML with no possibility that IDs will conflict. One
exception to this was that the footnotes were always put into an element
like
<aside id="foonotes" ...>
This commit applies the ID prefix to this ID as well.
| -rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 13 | ||||
| -rw-r--r-- | test/command/4235.md | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 473fd4c14..adabd302e 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -299,7 +299,7 @@ pandocToHtml opts (Pandoc meta blocks) = do if null (stNotes st) then return mempty else do - notes <- footnoteSection EndOfDocument (stEmittedNotes st + 1) (reverse (stNotes st)) + notes <- footnoteSection opts EndOfDocument (stEmittedNotes st + 1) (reverse (stNotes st)) modify (\st' -> st'{ stNotes = mempty, stEmittedNotes = stEmittedNotes st' + length (stNotes st') }) return notes st <- get @@ -524,8 +524,8 @@ tableOfContents opts sects = do -- | Convert list of Note blocks to a footnote <div>. -- Assumes notes are sorted. footnoteSection :: - PandocMonad m => ReferenceLocation -> Int -> [Html] -> StateT WriterState m Html -footnoteSection refLocation startCounter notes = do + PandocMonad m => WriterOptions -> ReferenceLocation -> Int -> [Html] -> StateT WriterState m Html +footnoteSection opts refLocation startCounter notes = do html5 <- gets stHtml5 slideVariant <- gets stSlideVariant let hrtag = if refLocation /= EndOfBlock @@ -550,7 +550,7 @@ footnoteSection refLocation startCounter notes = do ! A5.class_ className ! A5.role "doc-endnotes" $ x - | html5 = H5.aside ! A5.id "footnotes" + | html5 = H5.aside ! prefixedId opts "footnotes" ! A5.class_ className ! A5.role "doc-endnotes" $ x @@ -805,7 +805,7 @@ blockToHtmlInner opts (Div (ident, "section":dclasses, dkvs) if emitNotes then do st <- get - renderedNotes <- footnoteSection (writerReferenceLocation opts) + renderedNotes <- footnoteSection opts (writerReferenceLocation opts) (stEmittedNotes st + 1) (reverse notes) modify (\st' -> st'{ stNotes = mempty, stEmittedNotes = stEmittedNotes st' + length notes }) @@ -1084,7 +1084,8 @@ blockToHtml opts block = do then do notes <- if null (stNotes st) then return mempty - else footnoteSection (writerReferenceLocation opts) (stEmittedNotes st + 1) (reverse (stNotes st)) + else footnoteSection opts (writerReferenceLocation opts) + (stEmittedNotes st + 1) (reverse (stNotes st)) modify (\st' -> st'{ stNotes = mempty, stEmittedNotes = stEmittedNotes st' + length (stNotes st') }) return (doc <> notes) else return doc diff --git a/test/command/4235.md b/test/command/4235.md index 79114017f..adb379e92 100644 --- a/test/command/4235.md +++ b/test/command/4235.md @@ -4,7 +4,7 @@ This.^[Has a footnote.] ^D <p>This.<a href="#foofn1" class="footnote-ref" id="foofnref1" role="doc-noteref"><sup>1</sup></a></p> -<aside id="footnotes" class="footnotes footnotes-end-of-document" +<aside id="foofootnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes"> <hr /> <ol> |
