T11i Include-Code Smoke Test

#元 #测试 177 words 1 min read

Rendering verification for T11i. The include-code shortcode reads a file via readFile, wraps it in a fenced code block, and runs it through markdownify so Chroma applies syntax highlighting. This page exercises two languages — python and yaml — switched via the language= parameter.

1. Python (assets/snippets/hello.py)

def gcd(a: int, b: int) -> int:
    """Return the greatest common divisor of a and b."""
    while b:
        a, b = b, a % b
    return a


if __name__ == "__main__":
    print(gcd(12, 18))

2. YAML (assets/snippets/config.yaml)

server:
  host: 0.0.0.0
  port: 8080

logging:
  level: info
  format: json

features:
  - search
  - rss
  - sitemap

Self-check list

  • Both blocks render as <pre><code class="language-..."> rather than as raw source
  • Python block: keywords like def / if __name__ are colored by Chroma; docstring is colored too
  • YAML block: keys, strings, and numbers are colored per YAML rules (no fallback to plain text)
  • Line-height / font-size / background match every other fenced code block on the site
  • Both blocks remain readable in dark mode (syntax / background contrast holds)
  • Hugo build emits no readFile error