Перейти к содержанию

Pygments tokens usage

This document explains how BSL/SDBL lexers map code to Pygments tokens and how those tokens become CSS classes in Material for MkDocs. It is meant to help you build custom themes with predictable syntax colors.

How to read this file

Each token becomes a CSS class in the rendered HTML. Material for MkDocs then maps those classes to CSS variables like --md-code-hl-keyword-color. If a token has an empty flag, it means the lexer does not emit it.

Theming quick start

If you only want a solid base theme, focus on these CSS variables first:

  • --md-code-hl-keyword-color (keywords, control flow)
  • --md-code-hl-function-color (functions, types, namespaces)
  • --md-code-hl-variable-color (variables, properties)
  • --md-code-hl-string-color (strings, string escapes)
  • --md-code-hl-number-color (numbers)
  • --md-code-hl-comment-color (comments, doc sections)
  • --md-code-hl-operator-color (operators)
  • --md-code-hl-punctuation-color (punctuation)

Then refine:

  • --md-code-hl-special-color (escapes, preprocessor, special strings)
  • --md-code-hl-constant-color (builtins, constants)
  • --md-code-hl-generic-color (errors, generic output)

For full customization details, see the Material for MkDocs guide: Material for MkDocs: Custom syntax theme

BSL-focused examples

These snippets show how the lexer typically classifies elements. Use them as a visual target when adjusting your palette.

// Параметры:
//   Период - Дата - период расчета

Expected tokens:

  • // and doc text: Comment.Single
  • Параметры: Keyword
  • Период: Name.Variable
  • Дата: Name.Class
  • - and :: Punctuation
1
2
3
Если ЗначениеЗаполнено(Период) Тогда
    Сообщить("ОК");
КонецЕсли;

Expected tokens:

  • Если, Тогда, КонецЕсли: Keyword
  • ЗначениеЗаполнено: Name.Builtin
  • Период: Name.Variable
  • "ОК": Literal.String
  • (, ), ;: Punctuation
// РеквизитыКомпонент - Массив из см. ВнешниеКомпоненты.РеквизитыКомпоненты

Expected tokens:

  • РеквизитыКомпонент: Name.Variable
  • Массив: Name.Class
  • из, см.: Keyword
  • ВнешниеКомпоненты.РеквизитыКомпоненты: Name.Class

SDBL-focused examples

1
2
3
ВЫБРАТЬ
    ПОЛЕ
ИЗ Таблица

Expected tokens:

  • ВЫБРАТЬ, ИЗ: Keyword.Declaration
  • ПОЛЕ: Name.Variable
  • Таблица: Name.Class

Full token list

Below is the list of standard Pygments tokens and whether they are used by the BSL or SDBL lexers in this project. Columns show usage flags, the Material for MkDocs CSS class, and the palette variable most closely matching the token category.

Token BSL SDBL CSS class Color var
Comment c --md-code-hl-comment-color
Comment.Hashbang ch --md-code-hl-comment-color
Comment.Multiline cm --md-code-hl-comment-color
Comment.Preproc cp --md-code-hl-special-color
Comment.PreprocFile cpf --md-code-hl-string-color
Comment.Single c1 --md-code-hl-comment-color
Comment.Special cs --md-code-hl-comment-color
Error err --md-code-fg-color
Escape esc --md-code-fg-color
Generic g --md-code-fg-color
Generic.Deleted gd --md-typeset-del-color (background)
Generic.Emph ge --md-code-hl-generic-color
Generic.EmphStrong ges --md-code-fg-color
Generic.Error gr --md-code-hl-generic-color
Generic.Heading gh --md-code-hl-generic-color
Generic.Inserted gi --md-typeset-ins-color (background)
Generic.Output go --md-code-hl-generic-color
Generic.Prompt gp --md-code-hl-generic-color
Generic.Strong gs --md-code-hl-generic-color
Generic.Subheading gu --md-code-hl-generic-color
Generic.Traceback gt --md-code-hl-generic-color
Keyword k --md-code-hl-keyword-color
Keyword.Constant kc --md-code-hl-name-color
Keyword.Declaration kd --md-code-hl-keyword-color
Keyword.Namespace kn --md-code-hl-keyword-color
Keyword.Pseudo kp --md-code-hl-keyword-color
Keyword.Reserved kr --md-code-hl-keyword-color
Keyword.Type kt --md-code-hl-keyword-color
Literal l --md-code-hl-string-color
Literal.Date ld --md-code-fg-color
Literal.Number m --md-code-hl-number-color
Literal.Number.Bin mb --md-code-hl-number-color
Literal.Number.Float mf --md-code-hl-number-color
Literal.Number.Hex mh --md-code-hl-number-color
Literal.Number.Integer mi --md-code-hl-number-color
Literal.Number.Integer.Long il --md-code-hl-number-color
Literal.Number.Oct mo --md-code-hl-number-color
Literal.String s --md-code-hl-string-color
Literal.String.Affix sa --md-code-fg-color
Literal.String.Backtick sb --md-code-hl-string-color
Literal.String.Char sc --md-code-hl-string-color
Literal.String.Delimiter dl --md-code-fg-color
Literal.String.Doc sd --md-code-hl-comment-color
Literal.String.Double s2 --md-code-hl-string-color
Literal.String.Escape se --md-code-hl-special-color
Literal.String.Heredoc sh --md-code-hl-special-color
Literal.String.Interpol si --md-code-hl-string-color
Literal.String.Other sx --md-code-hl-special-color
Literal.String.Regex sr --md-code-hl-special-color
Literal.String.Single s1 --md-code-hl-string-color
Literal.String.Symbol ss --md-code-hl-string-color
Name n --md-code-hl-name-color
Name.Attribute na --md-code-hl-variable-color
Name.Builtin nb --md-code-hl-constant-color
Name.Builtin.Pseudo bp --md-code-hl-constant-color
Name.Class nc --md-code-hl-function-color
Name.Constant no --md-code-hl-constant-color
Name.Decorator nd --md-code-hl-keyword-color
Name.Entity ni --md-code-hl-keyword-color
Name.Exception ne --md-code-hl-function-color
Name.Function nf --md-code-hl-function-color
Name.Function.Magic fm --md-code-fg-color
Name.Label nl --md-code-hl-keyword-color
Name.Namespace nn --md-code-hl-function-color
Name.Other nx --md-code-fg-color
Name.Property py --md-code-fg-color
Name.Tag nt --md-code-hl-keyword-color
Name.Variable nv --md-code-hl-variable-color
Name.Variable.Class vc --md-code-hl-variable-color
Name.Variable.Global vg --md-code-hl-variable-color
Name.Variable.Instance vi --md-code-hl-variable-color
Name.Variable.Magic vm --md-code-fg-color
Operator o --md-code-hl-operator-color
Operator.Word ow --md-code-hl-operator-color
Other x --md-code-fg-color
Punctuation p --md-code-hl-punctuation-color
Punctuation.Marker pm --md-code-fg-color
Text - --md-code-fg-color
Text.Whitespace w --md-code-fg-color