fix(layouts): preserve inline HTML in title-cased body headings#1931
Merged
Conversation
`_markup/render-heading.html` ran `(title ($text | htmlUnescape)) | htmlEscape` on the heading text. Markdown-generated inline HTML such as <code>, <strong>, <em>, and <a> entered that pipeline as ordinary text from Go's perspective, so the `title` filter capitalized the first letter inside each tag name (<code> -> <Code>). The subsequent `htmlEscape` turned the mangled markup into entity-encoded text, leaving readers with literal "<Code>_c</Code>" in the rendered page. Switch to a CSS-driven approach: emit a `title-case` class on the heading element and let the browser apply `text-transform: capitalize`. The underlying HTML stays intact, inline markup keeps working, and capitalization is locale-aware via the `lang` attribute — useful for multilingual sites where different languages prefer different casing conventions. The existing `site.Params.main.titleCase` toggle and the per-page `exact: true` opt-out are preserved. The class-list building was unified across the two heading branches so the `title-case` and pre-existing `heading` classes (plus any IAL `.Attributes.class`) compose cleanly. Only `_markup/render-heading.html` carried this bug. Other title-casing sites in the theme (`header.html`, `docs/header.html`, `minimal/header.html`, `tags/list.html`, `_partials/head/seo.html`, `_partials/footer/social.html`, `_partials/page/taxonomy-*.html`) operate on frontmatter `title:` strings which are plain text and unaffected.
✅ Deploy Preview for gethinode-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
🎉 This PR is included in version 2.10.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_markup/render-heading.htmlran(title ($text | htmlUnescape)) | htmlEscapeon the heading text. Markdown-generated inline HTML such as, , , and entered that pipeline as ordinary text from Go's perspective, so thetitlefilter capitalized the first letter inside each tag name (->). The subsequenthtmlEscapeturned the mangled markup into entity-encoded text, leaving readers with literal "_c" in the rendered page.Switch to a CSS-driven approach: emit a
title-caseclass on the heading element and let the browser applytext-transform: capitalize. The underlying HTML stays intact, inline markup keeps working, and capitalization is locale-aware via thelangattribute — useful for multilingual sites where different languages prefer different casing conventions. The existingsite.Params.main.titleCasetoggle and the per-pageexact: trueopt-out are preserved.The class-list building was unified across the two heading branches so the
title-caseand pre-existingheadingclasses (plus any IAL.Attributes.class) compose cleanly.Only
_markup/render-heading.htmlcarried this bug. Other title-casing sites in the theme (header.html,docs/header.html,minimal/header.html,tags/list.html,_partials/head/seo.html,_partials/footer/social.html,_partials/page/taxonomy-*.html) operate on frontmattertitle:strings which are plain text and unaffected.