Search/

Highlight

Last modified:

A wrapper for applying syntax highlighting to code blocks.

React documentation

Last modified:

ℹ️ This feature doesn’t have a corresponding React component yet.

HTML

Last modified:

Rouge will parse and apply highlight styles via CSS classes to fenced code blocks that have a language specified.

For example:

```ruby
def what?
  42
end
```

would yield:

def what?
  42
end

Design

Last modified:

Highlight provides custom color schemes for the Ruby-based Rouge code syntax highlighter.

It supports colors for both light and dark themes.

Accessibility

Last modified:

Use <pre> and <code> to wrap code blocks.

Give context to code blocks using headings and short descriptive paragraphs, eg. specify the language, encoding, or file associated with the code block as relevant.

Rationale

Last modified:

This feature does not use the DS’ .bc- class prefix for its .highlight and .language-$lang classes because Rouge does/did not provide a means to set custom wrapping classes.

See also

Last modified:

  • Body (Foundations)
  • Markdown (Containers)