18F / 18f.gsa.gov

The 18F website
https://18f.gsa.gov
Other
293 stars 311 forks source link

replatform: missing id for headers (for anchors) #4038

Closed cantsin closed 1 month ago

cantsin commented 1 month ago

Example

--- original/work-with-us/index.html    2024-08-06 07:18:37.098383129 -0700
+++ changed/work-with-us/index.html 2024-08-06 07:26:02.352491511 -0700
-       <h2 id="service-offerings">
+       <h2>
beechnut commented 1 month ago

I inspected the output of the function defined in headingLinks.js which is supposed to turn h2s etc into heading links. The headingLinks function never encounters the h2 in question.

Investigating further, we find that the h2 in question is contained with in a {% capture ask-qs %} block, and later used in {{ ask-qs | markdownify }}.

However! markdownify uses a different set of configuration options than does the markdown renderer for the main site. Why? Because:

The capture-markdownify pattern strikes me as an antipattern. Why are we giving the page a directive to capture and render content, when it does that implicitly as part of the build process? The reason appears to be "because we're mixing HTML and markdown" but Markdown already allows HTML to pass through.

There are two primary solution options here:

Because markdownify is ONLY ever used in the capture-markdownify construct, my preference would be to remove the need for markdownify by rendering HTML/markdown content without it.

beechnut commented 1 month ago

Alright, well, that didn't work as expected

Screenshot 2024-08-06 at 4 35 23 PM

Confusing, because the renderer is set to allow HTML tags, so you'd think you could mix em.

beechnut commented 1 month ago

Aha, so Markdown does allow mixed Markdown/HTML...

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

BUT Markdown is not processed within HTML blocks other than <span>

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style emphasis inside an HTML block.

I think that means that the solution here is to refactor such that the markdownify filter uses the settings for the main site's Markdown renderer instead of being separate renderer.

I'll start on trying to refactor that mess.

beechnut commented 1 month ago

It's going ok! The files are refactored and mostly rendering, though the links are all unresolved Promises right now 😂

Screenshot 2024-08-07 at 3 19 00 PM
cantsin commented 1 month ago

Progress is progress!

beechnut commented 1 month ago

I guess you could say it's looking Promise-ing