Skip to main content

Module script

Module script 

Source
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_hint and friends.
sections
Section-header maps, one per content type. Port of the *_SECTIONS tables in XILP001_script_parser.py.
speakers
Speaker recognition: the CAST block, speakers.json, and the built-in fallback list. Port of the speaker half of XILP001_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.
ParseOpts
Options the caller supplies; season/season_title are the project.json fallbacks already resolved.
Parsed
Everything parse_script produces.
SpeakerStat
Per-speaker dialogue distribution, sorted by lines descending.

Statics§

ARC 🔒
EPISODE_N 🔒
EP_REST 🔒
QUOTED 🔒
SEASON_N 🔒
SEASON_OR_EPISODE 🔒

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, not 20).
nfc_normalize
NFC-normalize free text the same way parse_script normalizes 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. None when it carries no Episode N.
py_round1 🔒
round(x, 1) — banker’s rounding on the decimal representation, as CPython does it.
repr_f64
float_repr re-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 stats block from already-serialized entries (JSON key "type", not the Rust field name kind). Shared by Parsed::to_json and by anything that mutates a single entry in an already-written parsed_<tag>.json (e.g. the GUI’s dialogue-line editor) and needs to keep stats consistent with the edited entries array.