metanorma / metanorma-ogc

Metanorma processor for OGC documents
https://www.metanorma.com
BSD 2-Clause "Simplified" License
2 stars 3 forks source link

(URGENT, HTML) TOC order in HTML messed up #597

Closed ronaldtse closed 1 year ago

ronaldtse commented 1 year ago

Document: https://github.com/opengeospatial/Temporal-Abstract-Spec/pull/57

Screenshot 2023-10-31 at 6 09 51 PM
ghobona commented 1 year ago

Discussed with OGC Staff on 2023-11-06.

@opoudjis will ask a colleague to help out with JavaScript.

opoudjis commented 1 year ago

(Assuming that the ToC issue is Javascript.)

opoudjis commented 1 year ago

No, it's my side.

Headings in the ToC in HTML are sorting by line number of the HTML. But the <h1> and <h2> occasionally appear on the same line with no line break between them. Fixed by introducing h1 vs h2 as secondary sort order.

opoudjis commented 1 year ago

Screenshot 2023-11-12 at 16 54 14

opoudjis commented 1 year ago

Fix is not general enough: HTML is routinely putting very short clauses on the same line.

opoudjis commented 1 year ago

Pretty-printing HTML and then extracting line numbers, to make the line numbers accurately reflect ordering of nodes.

opoudjis commented 1 year ago

This has come back in https://github.com/metanorma/metanorma-iso/actions/runs/6968308642/job/18961953582?pr=1058

opoudjis commented 1 year ago

Awkward solution to guarantee one-line-per-element, seems to have worked.

opoudjis commented 1 year ago

AGAIN it has failed in Github Actions

Clearly using node.line in Nokogiri is not reliable in Windows, even if I pretty-print the XML beforehand: there is no guarantee that tags will print in separate lines. Instead, I am going to store the ordinal locations of all headers in HTML, and sort on those.