GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: improve section tag additions in HTML doc generator · nodejs/node@75ff8e6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • tools/doc
    • html.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tools/doc/html.mjs‎

Copy file name to clipboardExpand all lines: tools/doc/html.mjs
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ function processContent(content) {
7373
}
7474
// `++level` to convert the string to a number and increment it.
7575
content = content.replace(/(?<=<\/?h)[1-5](?=[^<>]*>)/g, (level) => ++level);
76-
// Wrap h3 tags in section tags.
76+
// Wrap h3 tags in section tags unless they are immediately preceded by a
77+
// section tag. The latter happens when GFM footnotes are generated. We don't
78+
// want to add another section tag to the footnotes section at the end of the
79+
// document because that will result in an empty section element. While not an
80+
// HTML error, it's enough for validator.w3.org to print a warning.
7781
let firstTime = true;
7882
return content
79-
.replace(/<h3/g, (heading) => {
83+
.replace(/(?<!<section [^>]+>)<h3/g, (heading) => {
8084
if (firstTime) {
8185
firstTime = false;
8286
return '<section>' + heading;

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.