I had an emdash in a post, and using --- for it, which gets transformed into — via Goldmark's Typographer extension if typographer = true is set in markup.toml, wasn't working in the summary text even though it was working in the main content of the post.
I realized it was because the summary text is not run through markdownify.
Fix
This PR runs all text through markdownify when it is reasonable to do so. Apart from applying Typographer if it's enabled, having it run through markdownify also allows for standard Hugo formatting things, like putting content within backticks into <code> tags. I updated a post in the example site with a summary set in order to test this.
Aside: markdownify does not automatically include emojify, even if enableEmoji is turned on in config (unfortunately this setting is not exposed as a site variable; see https://github.com/gohugoio/hugo/issues/9902), so if we wanted to support emojis in any of this text we'd have to turn it on everywhere.
Changes
In addition to regular post content (including tables of contents), the site author's description was already being run through markdownify, so no changes there.
The affected text includes:
titles: page titles, titles in excerpts, and titles in sidebar items
summary text
footer items (copyright text)
With <code> tags now possible in elements like a title, I changed the style for it from an fixed size (15px) to a relative one (85%), which maintains the existing size in body text.
This PR does not include these text items:
the page HTML <title> element
meta description text
social media (opengraph) text
because then you might have those <code> tags in what is supposed to be plaintext.
Screenshots (if applicable)
Before:
After (note syntax highlight and em-dash):
Checklist
Ensure you have checked off the following before submitting your PR.
Background
I had an emdash in a post, and using
---
for it, which gets transformed into—
via Goldmark's Typographer extension iftypographer = true
is set inmarkup.toml
, wasn't working in the summary text even though it was working in the main content of the post.I realized it was because the summary text is not run through
markdownify
.Fix
This PR runs all text through
markdownify
when it is reasonable to do so. Apart from applying Typographer if it's enabled, having it run throughmarkdownify
also allows for standard Hugo formatting things, like putting content within backticks into<code>
tags. I updated a post in the example site with a summary set in order to test this.Aside:
markdownify
does not automatically includeemojify
, even ifenableEmoji
is turned on in config (unfortunately this setting is not exposed as a site variable; see https://github.com/gohugoio/hugo/issues/9902), so if we wanted to support emojis in any of this text we'd have to turn it on everywhere.Changes
In addition to regular post content (including tables of contents), the site author's description was already being run through
markdownify
, so no changes there.The affected text includes:
With
<code>
tags now possible in elements like a title, I changed the style for it from an fixed size (15px) to a relative one (85%), which maintains the existing size in body text.This PR does not include these text items:
<title>
elementbecause then you might have those
<code>
tags in what is supposed to be plaintext.Screenshots (if applicable)
Before:
After (note syntax highlight and em-dash):
Checklist
Ensure you have checked off the following before submitting your PR.