Skip to content

Template interpolation in markdown content #204

@fasterthanlime

Description

@fasterthanlime

Summary

Allow template expressions ({{ }}) and shortcodes within markdown files, with recursive markdown processing of the output.

Motivation

Currently, templating only happens at the template level. But often you want to inject dynamic content directly into your markdown - a variable, a computed value, or a complex shortcode that wraps content.

Proposed Design

Simple interpolation

Support {{ var }} directly in markdown files:

# My Project

This codebase has {{ build.rust_loc }} lines of Rust.

Shortcode system (ported from cove)

Support the blockquote-emphasis shortcode syntax from cove:

> *:tip(title="Pro tip")*
>
> This content is inside the shortcode and gets processed as markdown.

Shortcodes are defined as templates in /templates/shortcodes/{name}.html.jinja.

Processing model

Recursive markdown processing: The output of {{ }} interpolation and shortcodes is processed as markdown. This allows:

  • Shortcodes to emit markdown that gets rendered
  • Dynamic content to include markdown formatting

Code block handling

Must be careful not to process {{ }} inside fenced code blocks or inline code. These should be left as-is.

Open questions

  • Exact timing in the markdown pipeline
  • How to handle errors in template expressions gracefully
  • Escaping mechanism if you want literal {{ }} in content (outside code blocks)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions