18F/18f.gsa.gov

replatform: missing id for headers (for anchors)

Closed this issue · 6 comments

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>

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 markdown config for the main site is long and convoluted, and hard to isolate as its own plugin
  • So we just used a simple, mostly unconfigured renderer for markdownify, meaning that the site markdown rendering and the markdownify filter are different.

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:

  • Figure out how to correctly configure the markdown renderer in isolation so it can be used as the renderer for the markdownify filter
  • Undo the capture-markdownify antipattern, rendering markdown normally within HTML

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.

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.

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.

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

Progress is progress!

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