Markup Entities¶
HTML entity encoding and decoding utilities.
Entities Module¶
HTML entity encoding and decoding utilities.
This submodule provides utilities for encoding text to HTML entities and decoding entities back to text.
Examples¶
from rite.markup.entities import ( ... entities_encode, ... entities_decode ... ) entities_encode("©") '©'
Modules¶
entities_decode
¶
Entity Decoder¶
Decode HTML entities to text.
Examples¶
from rite.markup.entities import entities_decode entities_decode("café") 'café'
Functions¶
entities_decode(text: str) -> str
¶
Decode HTML entities to text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Entity-encoded text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded text. |
Examples:
Notes
Decodes both numeric (&#N;) and named (©). Uses html.unescape from standard library.
entities_encode
¶
Entity Encoder¶
Encode text to HTML entities.
Examples¶
from rite.markup.entities import entities_encode entities_encode("café") 'café'
Functions¶
entities_encode(text: str, ascii_only: bool = False) -> str
¶
Encode text to HTML entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to encode. |
required |
ascii_only
|
bool
|
Encode only non-ASCII characters. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Entity-encoded text. |
Examples:
Notes
Converts characters to &#N; format. Useful for encoding special characters.
options: show_root_heading: true show_source: false heading_level: 2