Skip to content
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

Run more user-supplied text through markdownify #303

Merged
merged 7 commits into from
May 19, 2022
Merged

Conversation

rootwork
Copy link
Contributor

@rootwork rootwork commented May 16, 2022

Background

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 gohugoio/hugo#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:

nomarkdownify

After (note syntax highlight and em-dash):

markdownify

Checklist

Ensure you have checked off the following before submitting your PR.

@rootwork rootwork changed the title All text sourced from Markdown should be run through markdownify Run all text sourced from Markdown through markdownify May 16, 2022
@rootwork rootwork changed the title Run all text sourced from Markdown through markdownify Run more user-supplied text through markdownify May 16, 2022
@rootwork rootwork marked this pull request as ready for review May 16, 2022 22:57
@rootwork rootwork requested review from onweru and chipzoller May 16, 2022 22:57
@rootwork rootwork added the enhancement New feature or request label May 16, 2022
@onweru
Copy link
Collaborator

onweru commented May 16, 2022

@rootwork, I will review this asap. Thanks!

Copy link
Owner

@chipzoller chipzoller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good here, thank you!

@chipzoller
Copy link
Owner

Pending approval from @onweru

@chipzoller chipzoller merged commit ba091e2 into master May 19, 2022
@onweru onweru deleted the more-markdownify branch May 19, 2022 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants