inline

emphasis

Wire value: "emphasis"

Appears on: Documentation Topic, Tutorial (Project), Tutorial Article

1. How swift-docc-render consumes this

Grepping src/components/ for the literal string 'emphasis' lands, as with every other block/inline content kind on this reference site, on src/components/ContentNode.vue's wire-constant table. emphasis is one of the entries in the InlineType map (ContentNode.vue#L56-L69):

const InlineType = {
  codeVoice: 'codeVoice',
  emphasis: 'emphasis',
  image: 'image',
  ...
};

That constant is matched in the renderNode() factory function's switch (node.type) dispatch table, where emphasis falls through to the same case as the (currently unrelated) newTerm kind:

case InlineType.emphasis:
case InlineType.newTerm:
  return createElement('em', (
    renderChildren(node.inlineContent)
  ));

(ContentNode.vue#L437-L441.) Unlike most block kinds, emphasis is not delegated to a dedicated child component — it is turned directly into a bare native <em> element via Vue's createElement. The node's only payload field, inlineContent (an array of nested RenderInlineContent nodes), is recursively rendered through the same module-local renderChildren helper (ContentNode.vue#L122-L124) used by every other inline/block wrapper kind, so arbitrary nesting (for example strong inside emphasis, or a reference link inside emphasis) is rendered correctly by recursion rather than any special-casing. The type discriminator itself is consumed only by the switch and never forwarded into the DOM.

ContentNode.vue also has a tree-walking utility API (map, forEach, reduce) used elsewhere in the app to traverse a content tree without rendering it (for example, to build the plain-text abstract for search indexing or social-preview metadata). Both map and forEach explicitly list InlineType.emphasis alongside strong, inlineHead, superscript, subscript, strikethrough, and newTerm as "wrapper" kinds whose inlineContent array must be recursed into (ContentNode.vue#L564-L575, ContentNode.vue#L619-L628). No other .vue file under src/components/ or src/views/ matches the literal string 'emphasis'; the DocumentationTopic/ContentNode.vue and Article/ContentNode.vue files that also exist in the tree handle unrelated section-level concerns (list indentation, spacing) and do not reference this inline kind.

2. Example JSON and rendered mockup

Real fixture, from swift-docc's test suite: Tests/SwiftDocCTests/Rendering/Rendering Fixtures/term-lists-1.json (line 124), pinned at swift-docc@8b8d8268aa. This excerpt is a paragraph's inlineContent array containing plain text before and after an emphasis node:

{
  "type": "paragraph",
  "inlineContent": [
    {
      "type": "text",
      "text": "It has "
    },
    {
      "type": "emphasis",
      "inlineContent": [
        {
          "type": "text",
          "text": "multiple"
        }
      ]
    },
    {
      "type": "text",
      "text": " paragraphs."
    }
  ]
}

It has multiple paragraphs.

3. Data sheet

Field table for the Emphasis schema object (Sources/DocCArchive/Vendored/RenderNode.spec.json, one of the eleven members of the RenderInlineContent oneOf discriminator), cross-checked against the generated Components.Schemas.Emphasis struct in Sources/DocCArchive/generated/Types.swift:

FieldTypeRequired?Enum values / defaultNote
typestringyes"emphasis" | "italic"Discriminator. Generated as Emphasis._TypePayload, a String-backed enum with exactly these two cases. "italic" is accepted as a legacy/alternate spelling of the same node on the wire — both decode into the identical Emphasis struct; there is no separate behavior keyed off which spelling was used.
inlineContentarray of RenderInlineContentyes—The nested inline-content children to be rendered emphasized; generated as [Components.Schemas.RenderInlineContent]. Can itself contain further emphasis, strong, reference, etc. nodes.

Note the asymmetry with swift-docc's authoring-side Swift model: the in-memory RenderInlineContent Swift enum case at RenderInlineContent.swift#L36 is case emphasis(inlineContent: [RenderInlineContent]) — it only ever encodes with type: "emphasis" (see the InlineType Codable mapping at RenderInlineContent.swift#L61-L63). The "italic" wire alternative in the vendored JSON Schema exists purely as an input-side tolerance for decoding, not something swift-docc itself ever emits.

What an author writes to produce this: standard CommonMark emphasis syntax, either *text* or _text_, inside a documentation comment or a .md/.tutorial article. swift-docc's Markdown-to-render-tree compiler has a dedicated visitor, RenderContentCompiler.visitEmphasis(_:) (RenderContentCompiler.swift#L295-L296), which converts a parsed Markdown Emphasis node into exactly one RenderInlineContent.emphasis(inlineContent:) case, recursively visiting its Markdown children first.

4. HTML/CSS mapping in DocC-Render output

The rendered output is a bare <em>...</em> element with no id, class, or data-* attribute of its own — the createElement('em', renderChildren(node.inlineContent)) call at ContentNode.vue#L438-L441 passes no class/attrs object at all, unlike sibling cases such as InlineType.codeVoice (which adds class: 'inline-code') or InlineType.reference (which adds class: 'inline-link') a few lines away in the same switch. No SCSS file in src/styles/ targets the em element or defines a corresponding class; grepping the stylesheet tree for em { or a bare em selector turns up nothing beyond CSS length units (e.g. 1em, 2em) in unrelated rules. The emphasized (italic) appearance is therefore produced entirely by the browser's built-in default style for the <em> element (user-agent stylesheet font-style: italic), not by any DocC-render-authored CSS or custom property.

5. Modern CSS-only alternative

Not applicable

Current behavior, precisely: emphasis nodes are rendered as a plain, static <em> element via a one-line createElement('em', renderChildren(...)) call, with no Vue data, no props, no event handlers, and no client-side state of any kind attached to the element or its rendering path. There is nothing dynamic to reproduce: the "behavior" in play is simply the HTML semantics of <em> (stress emphasis) combined with the browser's default font-style: italic presentation, which is already the plain, non-JavaScript, non-interactive mechanism in use today. There is no toggleable, hidden, or otherwise stateful aspect of this kind for a native CSS mechanism (<details>, :target, the Popover API, :has(), etc.) to replace.