Skip to content

The HTML reader strips <ol>s within the HTML representation of footnotes #11852

Description

@omentic

Explain the problem.
The Pandoc HTML reader strips <ol>s within footnotes, when re-parsing footnote structure out of HTML.

[~]$ echo "meow meow meow#footnote[
       + Meow meow. Meow meow meow
       + Meow meow meow meow
      ] meow meow meow.#footnote[
        - Meow
        - Meow meow
        - Meow meow meow meow
      ] Meow." > meow.typ
[~]$ pandoc meow.typ -o meow-i.html
[~]$ pandoc meow-i.html -o meow-ii.html

While meow-i.html correctly has both an <ol> and a <ul> embedded as footnotes, meow-ii.html has stripped the <ol>.

Image Image

Pandoc version?
pandoc 3.10.2

Activity

  1. jgm commented on Sep 9, 2026

    @jgm
    Owner

    This has nothing to do with typst, so let's leave that out.

    meow-i.html:

    <p>meow meow meow<a href="#fn1" class="footnote-ref" id="fnref1"
    role="doc-noteref"><sup>1</sup></a> meow meow meow.<a href="#fn2"
    class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a>
    Meow.</p>
    <section id="footnotes" class="footnotes footnotes-end-of-document"
    role="doc-endnotes">
    <hr />
    <ol>
    <li id="fn1"><ol>
    <li><p>Meow meow. Meow meow meow</p></li>
    <li><p>Meow meow meow meow</p></li>
    </ol>
    <a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></li>
    <li id="fn2"><ul>
    <li><p>Meow</p></li>
    <li><p>Meow meow</p></li>
    <li><p>Meow meow meow meow</p></li>
    </ul>
    <a href="#fnref2" class="footnote-back" role="doc-backlink">↩︎</a></li>
    </ol>
    </section>
    
    
    % pandoc meow-i.html -t native
    % pandoc meow-i.html -t native
    [ Para
        [ Str "meow"
        , Space
        , Str "meow"
        , Space
        , Str "meow"
        , Note []
        , Space
        , Str "meow"
        , Space
        , Str "meow"
        , Space
        , Str "meow."
        , Note
            [ BulletList
                [ [ Para [ Str "Meow" ] ]
                , [ Para [ Str "Meow" , Space , Str "meow" ] ]
                , [ Para
                      [ Str "Meow"
                      , Space
                      , Str "meow"
                      , Space
                      , Str "meow"
                      , Space
                      , Str "meow"
                      ]
                  ]
                ]
            ]
        , SoftBreak
        , Str "Meow."
        ]
    ]
    

    Observation: the first footnote has become empty.

  2. jgm commented on Sep 9, 2026

    @jgm
    Owner

    First hunch: I think this is because in pOrderedList, we have

      isNoteList <- inFootnotes <$> getState

    and then later

      if isNoteList
         then do
           _ <- manyTill (eFootnote <|> pBlank) (pCloses "ol")
           return mempty

    Since <ol> closes <ol>, we stop parsing before we get to the content!
    https://github.com/jgm/pandoc/blob/main/src/Text/Pandoc/Readers/HTML.hs#L404-L434

  3. added a commit that references this issue on Oct 10, 2026
    4d7c614
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions