chipzoller / hugo-clarity

A theme for Hugo based on VMware Clarity
Other
572 stars 263 forks source link

Run more user-supplied text through markdownify #303

Closed rootwork closed 2 years ago

rootwork commented 2 years ago

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 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:

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.

onweru commented 2 years ago

@rootwork, I will review this asap. Thanks!

chipzoller commented 2 years ago

Pending approval from @onweru