yuin / goldmark

:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
MIT License
3.68k stars 255 forks source link

Footnotes: Using a section without heading causes validation errors #256

Closed danielfdickinson closed 2 years ago

danielfdickinson commented 3 years ago

https://github.com/yuin/goldmark/blob/829d874034a5048e1a5c6354dcd8b40e1e41c3a2/extension/footnote.go#L579

causes

| 175 | \

\
| Section lacks heading. Consider using “h2”-“h6” elements to add identifying headings to all sections. |

in W3C http://validator.w3.org/unicorn

There does not appear to be a way to configure the tag to use (e.g.) 'div' when using HTML5. I'm probably missing something, but I don't see a way to override this without changing footnote.go source file.

I do note that in the referenced https://michelf.ca/projects/php-markdown/extra/#footnotes that the example output given is

<p>That's some text with a footnote.
   <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>

<div class="footnotes" role="doc-endnotes">
<hr />
<ol>

<li id="fn:1" role="doc-endnote">
<p>And that's the footnote.
   <a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#8617;</a></p>
</li>

</ol>
</div>

which uses a div (but also looks like the XHTML version).

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

danielfdickinson commented 2 years ago

For what it's worth here are some articles on the status of outlines (sections) and headings:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements#multiple_h1_elements_on_one_page points to

Computer says no to the HTML5 outline A decade + a year of heading backwards

Basically, it's a mess of spec that was never implemented and never updated to reflect implementation.

kaushalmodi commented 2 years ago

I can confirm this HTML validation warning using this short example based on Hugo: test page | HTML validator page