parse_script#

Import

from scenet import parse_script

Defined in

scenet.frontends.script_front (source)

Install

pip install scenet

Since

0.1

Stability

Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how.

scenet.frontends.script_front.parse_script(text, *, source=None)[source]#

Parse a comic script into validated IR, one scene graph per panel, without compiling it.

The comic-script format is the one writers already use: PANEL headings, a description, then each speaker’s name in capitals over their line. Its front matter, between --- lines, is YAML.

Parameters:
  • text (str) – A comic script.

  • source (Path | None) – Path the text came from, prefixed to every error message.

Return type:

dict[str, PanelIR]

Returns:

Panel name to scene graph, in the order the panels appear.

Raises:

ScriptSyntaxError – The script cannot be parsed – no PANEL heading, or dialogue before the first – or a panel does not validate. Its line says where.

Note

A page heading groups panels for reading only; a script has no page layout.

Example

>>> from scenet import parse_script
>>> panels = parse_script(
...     "---\ncast: {ALICE: {reference: alice}}\n---\n"
...     "PANEL 1\n\nALICE\nYou forgot your umbrella!\n"
... )
>>> [event.text for event in next(iter(panels.values())).script]
['You forgot your umbrella!']

See also

compile_script, to compile it. load_script, to read a file.