The article describes the sample. A reusable component owns how that sample becomes safe HTML.

A code section in the article data names a language and contains source text. The blog-specific section renderer at blog.article.section.Code checks those fields and forwards them to the framework component text.html.CodeBlock. This keeps article knowledge in the blog and reusable code rendering in the framework.

The shared component decides whether a grammar is available. It maps the public language name livescript to the shared grammar ID lscript; JavaScript aliases map to their corresponding ECMAScript profiles; other grammar IDs pass through to the catalog. If a grammar is available, it asks the configured syntax highlighter for spans. If a language has no grammar, the source still renders as an ordinary preformatted block.

The rendered HTML carries its own stylesheet dependency

The code renderer escapes source text before it emits spans. A less-than sign in an example therefore stays text instead of becoming an HTML element. For highlighted output, the component returns both the HTML fragment and its resource dependencies through the generic HTML component contract. The stylesheet is inserted into the document's styles slot if that slot does not already contain it. This lets an on-demand article fragment bring the syntax styles it needs without building the site's component styles as one opaque file.

The same article rendering path feeds the Writing Studio's in-memory preview and the static article build. That matters during editing: the sample shown before saving uses the same component and highlighting rules as the later article page. There is one rendering behavior to inspect and maintain.

{ try-render: try-render-code-block } = dependency 'text.html.CodeBlock'

try-render = (section, syntax-highlighter) ->
  try-render-code-block {
    source: section.content
    language: section.language or 'text'
    annotations: section.annotations or []
    literal-highlights: section.literal-highlights
    syntax-highlighter: syntax-highlighter
    highlight-dependencies: [
      { key: 'astro-css', slot: 'styles', href: '../../../astro.css' }
      { key: 'article-syntax', slot: 'styles', href: '../../../components/article-syntax.css' }
    ]
  }

Grammar highlighting and literal highlighting are separate choices

A code block can use a grammar to classify source tokens, or it can use literal highlight rules to mark selected text directly. Literal rules take precedence when supplied: that block is rendered by the literal highlighter instead of the grammar highlighter. This is useful when a short example needs emphasis but does not justify a grammar, or when the author wants to call attention to a literal term in otherwise plain text.

The component boundary keeps those policies out of the article page renderer. It also gives the Writing Studio a predictable place to edit language choice, source text, annotations, and literal terms while preserving the article's data model.