Functions
register
Register content transformation functions with Jinja2 environment.
register
def register(env: Environment, site: Site) -> None
Register content transformation functions with Jinja2 environment.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
env |
Environment |
— | |
site |
Site |
— |
safe_html
Mark HTML as safe (prevents auto-escaping).
This is a marker function - Jinja2's 'safe' filter sho…
safe_html
def safe_html(text: str) -> str
Mark HTML as safe (prevents auto-escaping).
This is a marker function - Jinja2's 'safe' filter should be used instead. Included for compatibility with other SSGs.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | HTML text to mark as safe |
Returns
Same text (use with Jinja2's |safe filter)str
—
html_escape
Escape HTML entities.
Converts special characters to HTML entities:
- < becomes <
- > becomes &…
html_escape
def html_escape(text: str) -> str
Escape HTML entities.
Converts special characters to HTML entities:
- < becomes <
becomes >
- & becomes &
- " becomes "
- ' becomes '
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | Text to escape |
Returns
Escaped HTML textstr
—
html_unescape
Unescape HTML entities.
Converts HTML entities back to characters:
- < becomes <
- > becomes…
html_unescape
def html_unescape(text: str) -> str
Unescape HTML entities.
Converts HTML entities back to characters:
- < becomes <
- > becomes >
- & becomes &
- " becomes "
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | HTML text with entities |
Returns
Unescaped textstr
—
nl2br
Convert newlines to HTML <br> tags.
Replaces
with <br>
to preserve both HTML and text formatting.
nl2br
def nl2br(text: str) -> str
Convert newlines to HTML <br> tags.
Replaces
with <br> to preserve both HTML and text formatting.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | Text with newlines |
Returns
HTML with <br> tagsstr
—
smartquotes
Convert straight quotes to smart (curly) quotes.
Converts:
- " to " and "
- ' to ' and '
- -- to –…
smartquotes
def smartquotes(text: str) -> str
Convert straight quotes to smart (curly) quotes.
Converts:
- " to " and "
- ' to ' and '
- -- to –
- --- to —
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | Text with straight quotes |
Returns
Text with smart quotesstr
—
emojify
Convert emoji shortcodes to Unicode emoji.
Converts :emoji_name: to actual emoji characters.
emojify
def emojify(text: str) -> str
Convert emoji shortcodes to Unicode emoji.
Converts :emoji_name: to actual emoji characters.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
text |
str |
— | Text with emoji shortcodes |
Returns
Text with Unicode emojistr
—
extract_content
Extract content portion from full rendered HTML page.
Removes the page wrapper (html, head, body, …
extract_content
def extract_content(html: str) -> str
Extract content portion from full rendered HTML page.
Removes the page wrapper (html, head, body, navigation, footer) and extracts just the main content area. This is useful for embedding page content within other pages (e.g., track pages).
Tries multiple strategies to find content:
- Look for <article class="prose"> or <div class="docs-content">
- Look for <main> content (excluding nav/footer)
- Fall back to empty string if no content area found
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
html |
str |
— | Full rendered HTML page |
Returns
Extracted content HTML (or empty string if extraction fails)str
—