Expand description
Script parsing: the markdown production script → structured entries.
Port of XILP001_script_parser.py’s library half.
Modules§
- hints
- Scriptwriter pipe-hints on a direction: a source filename and per-cue
attribute overrides. Port of
_parse_direction_hintand friends. - sections
- Section-header maps, one per content type. Port of the
*_SECTIONStables inXILP001_script_parser.py. - speakers
- Speaker recognition: the CAST block,
speakers.json, and the built-in fallback list. Port of the speaker half ofXILP001_script_parser.py. - text
- Markdown normalization and line classification. Port of the standalone
text helpers in
XILP001_script_parser.py.
Structs§
- Entry
- One parsed script entry. Field order matches the pydantic model, which is the order they are serialized in.
- Header
- Header metadata: show, season, episode, title, season title.
- Parse
Opts - Options the caller supplies;
season/season_titleare theproject.jsonfallbacks already resolved. - Parsed
- Everything
parse_scriptproduces. - Speaker
Stat - Per-speaker dialogue distribution, sorted by lines descending.
Statics§
Functions§
- compute_
speaker_ stats - emit_
directions 🔒 - Emit one direction entry per recognized bracket on a line.
- json_
f64 🔒 - A float that serializes the way Python writes it (
20.0, not20). - nfc_
normalize - NFC-normalize free text the same way
parse_scriptnormalizes the raw script (below), so a hand-edited dialogue line and a re-parsed one can’t diverge by decomposition form. - opt_str 🔒
- parse_
script - Parse a markdown production script into sequence-numbered entries.
- parse_
script_ header - Parse the first non-empty script line.
Nonewhen it carries noEpisode N. - py_
round1 🔒 round(x, 1)— banker’s rounding on the decimal representation, as CPython does it.- repr_
f64 float_reprre-exported for callers writing stat values into JSON.- speakers_
for_ cast - Speaker display order used by the cast skeleton.
- stats_
from_ entries_ json - Recompute the
statsblock from already-serialized entries (JSON key"type", not the Rust field namekind). Shared byParsed::to_jsonand by anything that mutates a single entry in an already-writtenparsed_<tag>.json(e.g. the GUI’s dialogue-line editor) and needs to keepstatsconsistent with the editedentriesarray.