-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render all Nunjucks before Markdown runs #2565
Conversation
Allows Nunjucks to render first any HTML that’s incompatible with Markdown
✅ You can preview this change here:
To edit notification comments on pull requests, go to your Netlify site settings. |
This looks good in principle. I wonder if it's worth sticking a beautify step in between the Nunjucks and the Markdown. It shouldn't affect displayed code blocks at all, but should hopefully limit the future diff between updates if somebody's made changes to a Nunjucks template but not worried about whitespace control. I'm also wondering (but way out of scope for this PR) whether we should run a diff between the main branch's compiled code and PRs, sorta like the dist diff check on govuk-frontend: https://github.com/alphagov/govuk-frontend/blob/main/.github/workflows/diff-change-to-dist.yaml Just feels like we don't have any easy way of checking diff except for manually doing it locally. I've popped in a possible thing to validate the compiled HTML, but that won't necessarily mean it doesn't hideously break something. I'm now just using this comment as a sounding board! Whaddya think? |
@domoscargin Brill. Thanks for looking at this one too: Have you noticed anything else? I'm a bit aware that a HTML beautifier might hide potential whitespace issues, had a bit of hesitance to keep the Knowing it's an issue, I've added this PR too: 👆 Hopefully we can be fully happy in one repo ( |
I was thinking more of the non-code block Design System website specific stuff (the In terms of slight annoyances now, the cookie banner is also doing slightly eye-twitchy things with this code < <div class="govuk-cookie-banner__content">
< <p class="govuk-body">We’d like to use analytics cookies so we can understand how you use the Design System and make improvements.</p>
---
> <div class="govuk-cookie-banner__content"> <p class="govuk-body">We’d like to use analytics cookies so we can understand how you use the Design System and make improvements.</p> But wrestling with Nunjucks whitespace control proved too annoying for me last night, and it's not really an issue, just irritating. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks!
I've added an issue for doing something with the compiled diff: #2574
But this is good to go.
This PR lays the groundwork to fix a bug lurking in our Metalsmith build
Notice how we sometimes render code blocks via Nunjucks:
Or using a global + opt-in syntax highlighting filter:
But sometimes rendering via Markdown with automatic syntax highlighting:
This "works" but stray line breaks can trigger a double-highlight or double-render (code escaped twice) with both render stages (Nunjucks/Markdown) each calling into
highlight.js
After this PR is merged we:
@metalsmith/in-place
@metalsmith/markdown