httk.serve.web.widgets.extraction¶
Renderer-aware extraction of literal-only widget(...) invocations.
Functions¶
|
Parse one literal-only widget invocation without evaluating it. |
|
Create a stable renderer placement for one widget invocation. |
|
Replace standalone Markdown widget paragraphs while excluding code blocks. |
|
Extract complete HTML widget blocks while skipping code-like tags. |
Module Contents¶
- httk.serve.web.widgets.extraction.parse_widget_invocation(text, *, source_path, line, column)[source]¶
Parse one literal-only widget invocation without evaluating it.
- Parameters:
text (str) – Complete widget invocation text.
source_path (pathlib.Path) – Source file containing the invocation.
line (int) – One-based source line.
column (int) – One-based source column.
- Returns:
Widget name and validated literal properties.
- Raises:
httk.serve.web.model.errors.WidgetParseError – If the invocation is not literal-only.
httk.serve.web.model.errors.WidgetValidationError – If a property value is invalid.
- Return type:
- httk.serve.web.widgets.extraction.placement_for(text, *, source_path, line, column, index)[source]¶
Create a stable renderer placement for one widget invocation.
- Parameters:
text (str) – Complete widget invocation text.
source_path (pathlib.Path) – Source file containing the invocation.
line (int) – One-based source line.
column (int) – One-based source column.
index (int) – Zero-based placement index in the source.
- Returns:
Parsed widget placement with a deterministic placeholder.
- Return type:
- httk.serve.web.widgets.extraction.markdown_source(source, source_path, *, line_offset=0)[source]¶
Replace standalone Markdown widget paragraphs while excluding code blocks.
- Parameters:
source (str) – Markdown source text.
source_path (pathlib.Path) – Source file containing the text.
line_offset (int) – Number of lines preceding the supplied source.
- Returns:
Source with placeholders and the extracted placements.
- Return type:
tuple[str, tuple[httk.serve.web.renderers.base.WidgetPlacement, Ellipsis]]
- httk.serve.web.widgets.extraction.html_source(source, source_path)[source]¶
Extract complete HTML widget blocks while skipping code-like tags.
- Parameters:
source (str) – HTML source text.
source_path (pathlib.Path) – Source file containing the text.
- Returns:
Source with placeholders and the extracted placements.
- Return type:
tuple[str, tuple[httk.serve.web.renderers.base.WidgetPlacement, Ellipsis]]