Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

The DescriptionGenerator#describe filter converts Markdown to HTML without rendering Liquid first, causing raw tags like {% local %} to appear in meta descriptions.

Changes

  • Liquid preprocessing: Render Liquid tags before Markdown conversion using $site.liquid_renderer with full site payload and registers
  • Error handling: Wrap in begin/rescue, fall back to original input on failure, log warning via Jekyll.logger.warn
  • Backward compatibility: Only render Liquid when $site is defined

Example

Before:

<meta property="og:description" content="Meeting at {% local '2024-01-01 10:00' %}">

After:

<meta property="og:description" content="Meeting at Monday, January 1, 2024 at 10:00 AM EST">

Implementation

markdown = input.to_s

# Render Liquid tags first if $site is defined
if defined?($site) && $site
  begin
    markdown = $site.liquid_renderer.file("(cs50-describe)").parse(markdown).render!($site.site_payload, { :registers => { :site => $site } })
  rescue => e
    Jekyll.logger.warn "CS50 warning: failed to render Liquid in description: #{e.message}"
    markdown = input.to_s
  end
end

# Convert Markdown to HTML
html = $site.find_converter_instance(::Jekyll::Converters::Markdown).convert(markdown)
Original prompt

Problem: DescriptionGenerator#describe converts input Markdown to HTML but does not render Liquid first. As a result, Liquid tags (including plugin tags like {% local %}) can appear raw in generated descriptions (e.g., in meta tags).

Goal: Make a minimal change so DescriptionGenerator#describe first renders any Liquid in the input using the site's Liquid renderer and payload (so plugins/tags/filters expand), then converts the result to HTML with the Markdown converter. Keep change small and safe: wrap Liquid rendering in begin/rescue and fall back to original input on error; use $site.site_payload and registers => { :site => $site } to provide context to the renderer.

Tasks:

  • Edit lib/jekyll-theme-cs50.rb: inside module CS50::DescriptionGenerator#describe, before converting to HTML, render the input string through $site.liquid_renderer.file("(cs50-describe)").parse(markdown).render!($site.site_payload, { :registers => { :site => $site } }) if $site is defined. Wrap in rescue and log a Jekyll warning if rendering fails.
  • Keep all other logic unchanged.

Testing notes:

  • After change, run jekyll build and confirm meta descriptions no longer contain raw Liquid tags like {% local %}.

Files to modify:

  • lib/jekyll-theme-cs50.rb

Make the change and open a pull request with a concise title and description. Commit message: "Render Liquid in DescriptionGenerator before Markdown conversion".

This pull request was created as a result of the following prompt from Copilot chat.

Problem: DescriptionGenerator#describe converts input Markdown to HTML but does not render Liquid first. As a result, Liquid tags (including plugin tags like {% local %}) can appear raw in generated descriptions (e.g., in meta tags).

Goal: Make a minimal change so DescriptionGenerator#describe first renders any Liquid in the input using the site's Liquid renderer and payload (so plugins/tags/filters expand), then converts the result to HTML with the Markdown converter. Keep change small and safe: wrap Liquid rendering in begin/rescue and fall back to original input on error; use $site.site_payload and registers => { :site => $site } to provide context to the renderer.

Tasks:

  • Edit lib/jekyll-theme-cs50.rb: inside module CS50::DescriptionGenerator#describe, before converting to HTML, render the input string through $site.liquid_renderer.file("(cs50-describe)").parse(markdown).render!($site.site_payload, { :registers => { :site => $site } }) if $site is defined. Wrap in rescue and log a Jekyll warning if rendering fails.
  • Keep all other logic unchanged.

Testing notes:

  • After change, run jekyll build and confirm meta descriptions no longer contain raw Liquid tags like {% local %}.

Files to modify:

  • lib/jekyll-theme-cs50.rb

Make the change and open a pull request with a concise title and description. Commit message: "Render Liquid in DescriptionGenerator before Markdown conversion".


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix Liquid rendering in DescriptionGenerator Render Liquid tags in DescriptionGenerator before Markdown conversion Oct 28, 2025
Copilot AI requested a review from dmalan October 28, 2025 15:32
Copilot finished work on behalf of dmalan October 28, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants