Skip to content

Conversation

@skiadas
Copy link
Contributor

@skiadas skiadas commented Jul 17, 2025

This should be addressing #2606 but also includes a fair amount of refactoring:

  • Created a heading-generic template to uniformly handle the common elements to all heading generations (determining tag from heading, adding heading class). All other heading-generating templates now call on this one.
  • Add boolean parameter to this heading-generic template and any others that needed it to indicate that the headings should actually become links back to the original location of those headings.
  • Added some test cases to the sample article for heading cases that appeared to not be getting tested.

@Alex-Jordan
Copy link
Contributor

Alex-Jordan commented Jul 17, 2025

I haven't looked closely at this, but I note that it touches on a lot of delciate code that ensures heading levels elevate correctly. Like, not following an h2 with an h4 without using an h3 in between. Are you confident that this behavior is preserved?

I used the Firefox headingsMap extension a lot when we put all that together. It highlights when headings are out of line like that. There are still things that it won't catch, that need manual eyes. For example, if there are adjacent headings that should be h2, h3, but this change makes them h2, h2, then only manual oversight can see that.

One of the complications is that the heading level of something where it is born might be (for example) 3. But then when that thing appears somewhere else, like in a "solutions" page, it may need a different heading level.

@skiadas
Copy link
Contributor Author

skiadas commented Jul 17, 2025

I haven't looked closely at this, but I note that it touches on a lot of delicate code that ensures heading levels elevate correctly. Like, not following an h2 with an h4 without using an h3 in between. Are you confident that this behavior is preserved?

I'm as confident as I can be I suppose. So the first two commits add new "tests", then the moving around is done on the 3rd and 4th commit, and my guide throughout that process was a before- and after- diff of the sample-article build with the publication-crc settings, and observing that the versions are identical (except for the obviously different compile-time timestamp). So at least on the sample-article source code the results of the refactoring should be identical to the before state.

Then the last commit, which adds the backlinks, simply surrounds the title part with an anchor tag (does this need any accessibility extras btw?).

The algorithm for determining what heading level to use has remained unaffected as far as I can tell, in the mode="hN" template. But yes it's a biggish change, which is why I wanted as many eyes on it as possible.

Are there other projects that I should use as test cases, beyond the sample article?

@Alex-Jordan
Copy link
Contributor

If you were doing diffs on the output HTML from the sample article, that is great. It has all of the complicated cases from when this was tested before, and no other projects were used in testing at that time. If you didn't see any "hN" changing their level, I'd be confident things are good in that front.

If it's not much trouble, if you can post the sample article build somewhere public, I'd look at the accessibility question you asked.

@skiadas
Copy link
Contributor Author

skiadas commented Jul 17, 2025

@skiadas
Copy link
Contributor Author

skiadas commented Aug 11, 2025

Let's see if this works: https://skiadas.github.io/temp-sample-backlinks/derivatives.html

@Alex-Jordan Did you have a chance to review this by any chance?

@skiadas skiadas force-pushed the solutions-exercise-backlink branch from 7eb70e8 to 47e3431 Compare August 11, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants