# emphasis

URL: /patitas/api/parsing/inline/emphasis/
Section: inline
Description: Emphasis parsing for Patitas parser.

Implements CommonMark delimiter stack algorithm for emphasis/strong.
See: https://spec.commonmark.org/0.31.2/#emphasis-and-strong-emphasis

Thread Safety:
All methods are stateless or use instance-local state only.
Safe for concurrent use when each parser instance is used by one thread.

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/parsing/inline/emphasis/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Finline%2Femphasis%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Finline%2Femphasis%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Finline%2Femphasis%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fparsing%2Finline%2Femphasis%2Findex.txt)

Module

#
`parsing.inline.emphasis`

Emphasis parsing for Patitas parser.

Implements CommonMark delimiter stack algorithm for emphasis/strong.
See: https://spec.commonmark.org/0.31.2/#emphasis-and-strong-emphasis

Thread Safety:

All methods are stateless or use instance-local state only.
Safe for concurrent use when each parser instance is used by one thread.

1Class

## Classes

`EmphasisMixin`

5

▼

Mixin for emphasis delimiter processing.

Implements CommonMark flanking rules and delimiter matchi…

Mixin for emphasis delimiter processing.

Implements CommonMark flanking rules and delimiter matching algorithm.
Uses external MatchRegistry for match tracking (enables immutable tokens).

Required Host Attributes: None

Required Host Methods: None

#### Methods

Internal Methods
5

▼

`_is_left_flanking`

3

`bool`

▼

Check if delimiter run is left-flanking.

Left-flanking: not followed by whites…

`def _is_left_flanking(self, before: str, after: str, delim: str) -> bool`

Check if delimiter run is left-flanking.

Left-flanking: not followed by whitespace, and either:

- not followed by punctuation, OR

- preceded by whitespace or punctuation

##### Parameters

Name
Type
Description

`before`
`—`

`after`
`—`

`delim`
`—`

##### Returns

`bool`

`_is_right_flanking`

3

`bool`

▼

Check if delimiter run is right-flanking.

Right-flanking: not preceded by whit…

`def _is_right_flanking(self, before: str, after: str, delim: str) -> bool`

Check if delimiter run is right-flanking.

Right-flanking: not preceded by whitespace, and either:

- not preceded by punctuation, OR

- followed by whitespace or punctuation

##### Parameters

Name
Type
Description

`before`
`—`

`after`
`—`

`delim`
`—`

##### Returns

`bool`

`_is_whitespace`

1

`bool`

▼

Check if character is Unicode whitespace.

CommonMark uses Unicode whitespace f…

`def _is_whitespace(self, char: str) -> bool`

Check if character is Unicode whitespace.

CommonMark uses Unicode whitespace for emphasis flanking rules.
Includes ASCII whitespace and Unicode category Zs.

##### Parameters

Name
Type
Description

`char`
`—`

##### Returns

`bool`

`_is_punctuation`

1

`bool`

▼

Check if character is Unicode punctuation.

CommonMark uses Unicode punctuation…

`def _is_punctuation(self, char: str) -> bool`

Check if character is Unicode punctuation.

CommonMark uses Unicode punctuation for emphasis flanking rules.
Includes ASCII punctuation and Unicode categories P* and S*.

##### Parameters

Name
Type
Description

`char`
`—`

##### Returns

`bool`

`_process_emphasis`

2

`MatchRegistry (/patitas/api/parsing/inline/match_registry/#MatchRegistry)`

▼

Process delimiter stack to match emphasis openers/closers.

Implements CommonMa…

`def _process_emphasis(self, tokens: list[InlineToken], registry: MatchRegistry | None = None) -> MatchRegistry`

Process delimiter stack to match emphasis openers/closers.

Implements CommonMark emphasis algorithm using external match tracking.
Uses a Delimiter-Index to achieve O(n) average performance.

##### Parameters

Name
Type
Description

`tokens`
`—`

List of InlineToken NamedTuples from _tokenize_inline().

`registry`
`—`

Optional MatchRegistry to use. If None, creates a new one.

Default:`None`

##### Returns

`MatchRegistry (/patitas/api/parsing/inline/match_registry/#MatchRegistry)`

MatchRegistry containing all delimiter matches.
