Module

rendering.plugins.directives.validator

Pre-parse validation for directives.

Validates directive syntax before parsing to catch errors early with helpful messages.

Classes

DirectiveSyntaxValidator
Validates directive syntax before parsing. Catches common errors early with helpful messages befor…
7

Validates directive syntax before parsing.

Catches common errors early with helpful messages before expensive parsing and recursive markdown processing.

Methods 7

validate_tabs_directive staticmethod
Validate tabs directive content.
3 list[str]
def validate_tabs_directive(content: str, file_path: Path | None = None, line_number: int | None = None) -> list[str]

Validate tabs directive content.

Parameters 3
content str

Directive content (between opening and closing backticks)

file_path Path | None

Optional file path for error messages

line_number int | None

Optional line number for error messages

Returns

list[str]

List of validation error messages (empty if valid)

validate_code_tabs_directive staticmethod
Validate code-tabs directive content.
3 list[str]
def validate_code_tabs_directive(content: str, file_path: Path | None = None, line_number: int | None = None) -> list[str]

Validate code-tabs directive content.

Parameters 3
content str

Directive content

file_path Path | None

Optional file path

line_number int | None

Optional line number

Returns

list[str]

List of validation errors

validate_dropdown_directive staticmethod
Validate dropdown directive content.
4 list[str]
def validate_dropdown_directive(content: str, title: str = '', file_path: Path | None = None, line_number: int | None = None) -> list[str]

Validate dropdown directive content.

Parameters 4
content str

Directive content

title str

Directive title

file_path Path | None

Optional file path

line_number int | None

Optional line number

Returns

list[str]

List of validation errors

validate_admonition_directive staticmethod
Validate admonition directive content.
4 list[str]
def validate_admonition_directive(admon_type: str, content: str, file_path: Path | None = None, line_number: int | None = None) -> list[str]

Validate admonition directive content.

Parameters 4
admon_type str

Type of admonition (note, tip, warning, etc.)

content str

Directive content

file_path Path | None

Optional file path

line_number int | None

Optional line number

Returns

list[str]

List of validation errors

validate_nested_fences staticmethod
Validate nested fence usage (colon fences). Checks for: 1. Unclosed fences 2. …
2 list[str]
def validate_nested_fences(content: str, file_path: Path | None = None) -> list[str]

Validate nested fence usage (colon fences).

Checks for:

  1. Unclosed fences
  2. Mismatched closing fence lengths
  3. Nested directives using same fence length as parent (ambiguous)
Parameters 2
content str

Markdown content

file_path Path | None

Optional file path

Returns

list[str]

List of error/warning messages

validate_directive classmethod
Validate any directive type.
6 list[str]
def validate_directive(cls, directive_type: str, content: str, title: str = '', options: dict[str, Any] | None = None, file_path: Path | None = None, line_number: int | None = None) -> list[str]

Validate any directive type.

Parameters 6
directive_type str

Type of directive (tabs, note, dropdown, etc.)

content str

Directive content

title str

Directive title (if any)

options dict[str, Any] | None

Directive options dictionary

file_path Path | None

Optional file path

line_number int | None

Optional line number

Returns

list[str]

List of validation errors (empty if valid)

validate_directive_block classmethod
Validate a complete directive block from markdown.
3 dict[str, Any]
def validate_directive_block(cls, directive_block: str, file_path: Path | None = None, start_line: int | None = None) -> dict[str, Any]

Validate a complete directive block from markdown.

Parameters 3
directive_block str

Full directive block including opening/closing backticks

file_path Path | None

Optional file path

start_line int | None

Optional starting line number

Returns

dict[str, Any]

Dictionary with validation results:

{
    'valid': bool,
    'errors': List[str],
    'directive_type': str,
    'content': str,
    'title': str,
    'options': Dict[str, Any]
}

Functions

validate_markdown_directives
Validate all directive blocks in a markdown file.
2 list[dict[str, Any]]
def validate_markdown_directives(markdown_content: str, file_path: Path | None = None) -> list[dict[str, Any]]

Validate all directive blocks in a markdown file.

Parameters 2

Name Type Default Description
markdown_content str

Full markdown content

file_path Path | None None

Optional file path for error reporting

Returns

list[dict[str, Any]]

List of validation results, one per directive block

get_directive_validation_summary
Get a summary of directive validation results.
1 dict[str, Any]
def get_directive_validation_summary(validation_results: list[dict[str, Any]]) -> dict[str, Any]

Get a summary of directive validation results.

Parameters 1

Name Type Default Description
validation_results list[dict[str, Any]]

List of validation result dictionaries

Returns

dict[str, Any]

Summary dictionary with counts and error lists