T11i Include-Code 冒烟测试

#元 #测试 共 321 字 约 1 分钟

T11i 渲染验证。include-code shortcode 走 readFile,把内容包成 fenced code 再 markdownify,最终走 Chroma 高亮。本页验证两种语言(python / yaml)的 fixture 切换。

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

自检清单

  • 两段都呈 <pre><code class="language-..."> 而不是源码字符
  • Python 段:def / if __name__ 等关键字被 Chroma 着色,docstring 也染色
  • YAML 段:键、字符串、数字按 yaml 规则着色(不退化成纯文本)
  • 行高 / 字号 / 背景与站点其他 fenced 代码块一致
  • 暗色模式两段都仍可读(语法配色与背景对比足够)
  • Hugo 构建无 readFile 错误