Geonovum / respec

A tool for creating technical documents and web standards. Geonovum fork to modify respec for own use.
Other
2 stars 1 forks source link

No TOC with new build #152

Closed thijsbrentjens closed 6 years ago

thijsbrentjens commented 6 years ago

Important info

Description of problem

What happened (e.g., it crashed)?: no TOC generated for https://broprogramma.github.io/GAR/. It was in the previous Geonovum build

thijsbrentjens commented 6 years ago

Maybe it is related to missing headers for sections. See console: Alle secties moeten beginnen met een h2-6 element. Voeg een h2-6 toe aan de conflicterende sectie of gebruik een <div>. Zie de developer console. ("no-headingless-sections" x 78)

And check build or create a new build.

marcoscaceres commented 6 years ago

@thijsbrentjens could you try setting the spec up locally (e.g., put it into "examples/gar.html") and check if it's throwing any errors?

lvdbrink commented 6 years ago

May also be browser related... the affected spec, and one other spec I checked, are now working correctly with the current GN build in Chrome/Opera, but not in Edge.

marcoscaceres commented 6 years ago

Comfirm that it’s working ok in other browsers. Could either of you please let me know about any errors in Edge?

lvdbrink commented 6 years ago

It's now working ok in Edge too (as of just now when I checked). I don't know if @thijsbrentjens deployed another build?

thijsbrentjens commented 6 years ago

I reverted the build on our prod environment, so that explains why there is a TOC now maybe. I'll set it up locally and try to find out more.

thijsbrentjens commented 6 years ago

So the errors I get locally are:

TypeError: "Argument 1 of Node.appendChild is not an object."

There are also some section elements in this document without a heading (h2-h6).

I narrowed the source of the issue down to this document: https://broprogramma.github.io/GAR/data/GAR-cat.html that causes the TOC not to be generated. It contains sections with invalid headings (h7 / h8). But this did not cause the issue (@lvdbrink but I think it should be changed).

The source of the issue is that in that document there are empty anchors (in headings):

<a href="#"></a>

I removed these from the document (locally) and now a TOC is generated with our latest build.

marcoscaceres commented 6 years ago

Ok, cool. We should add a fix for that nonetheless. Please make sure you keep a sample of the bad markup so we can reproduce it :) (🏺🐛)

thijsbrentjens commented 6 years ago

Ok.

Maybe it's not a nice fix (it is a bit weird to add an extra condition because the do/while statement already is conditionally), but in the renameElement function in core/utils.js I added a condition around the part that copies the child nodes to check for the firstChild existence:

  do {
     if (elem.firstChild) newElement.appendChild(elem.firstChild);
  } while (elem.firstChild);

I could create a PR if you think this is a good solution.

thijsbrentjens commented 6 years ago

Closing this issue, because we need to fix a specific doc (and we can use the current local build in the meantime now).