Cotton code
151 lines · 10.8 KB · JSONRaw
{  "about": "Cotton Screenplays' Fountain rule (cotton_rules::fountain). `sample` names the synthetic two-scene script every surface seeds and tests with (`@sample` in a case): invented, from no real script. `documents`: a whole .fountain read into its title page and scenes, and `written` what writing that document back gives (absent: the text itself). `lines`: each line of a scene body, what it is. `press`: Return or Tab at a caret (line, UTF-16 column), the body after, the caret, and the kind its line is set as. `headings`: a heading's parts. `complete`: the names that complete what is typed on a cue line. `pages`: each scene's lines on the page, its page span. Read by cotton-rules' fountain tests and the phone's screenplays methods.",  "sample": "fountain_sample.fountain",  "documents": [    {      "name": "the sample: a title page and two scenes, the transition staying with the scene it ends",      "text": "@sample",      "title_page": [        { "key": "Title", "value": "The Invented Lighthouse" },        { "key": "Credit", "value": "Written by" },        { "key": "Author", "value": "A. Sample" },        { "key": "Draft date", "value": "12 November 2026" }      ],      "scenes": [        { "heading": "EXT. HEADLAND LIGHTHOUSE - DUSK", "body": "Wind flattens the grass. A lamp turns, slow, above a door painted the colour of rust.\n\nIRA (60s), the keeper, winds a brass crank. Each turn is a small argument with the dark.\n\nIRA\nEleven more turns. Then the light keeps itself till midnight.\n\nCUT TO:" },        { "heading": "INT. LIGHTHOUSE - LAMP ROOM - NIGHT", "body": "TEO (20s), a clerk with a folder held like a shield, climbs the last stair, out of breath.\n\nTEO\n(reading)\nThe board thanks you for forty years of service.\n\nIRA\nThe board has never climbed these stairs.\n\nShe hands him the crank.\n\nIRA (CONT'D)\nTurn. The storm won't read your letter." }      ]    },    {      "name": "no title page; words before the first heading are a scene with no heading",      "text": "A cold open, before any place.\n\nINT. HALL - DAY\n\nFootsteps.\n",      "title_page": [],      "scenes": [        { "heading": null, "body": "A cold open, before any place." },        { "heading": "INT. HALL - DAY", "body": "Footsteps." }      ]    },    {      "name": "a forced heading loses its dot when read and gets it back when written",      "text": ".THE ROOF\n\nRain.\n",      "title_page": [],      "scenes": [ { "heading": "THE ROOF", "body": "Rain." } ]    },    {      "name": "a heading must stand after a blank line; one inside a paragraph is action, and is written forced as action so it reads back so",      "text": "INT. ATTIC - NIGHT\nint. cellar is written on the box.\n",      "title_page": [],      "scenes": [ { "heading": "INT. ATTIC - NIGHT", "body": "int. cellar is written on the box." } ],      "written": "INT. ATTIC - NIGHT\n\n!int. cellar is written on the box.\n"    },    {      "name": "a title value of several lines, indented under its key; CRLF read as LF",      "text": "Title:\r\n   THE INVENTED\r\n   LIGHTHOUSE\r\nContact: sample@example.invalid\r\n\r\nEXT. SEA - DAY\r\n\r\nWaves.\r\n",      "title_page": [        { "key": "Title", "value": "THE INVENTED\nLIGHTHOUSE" },        { "key": "Contact", "value": "sample@example.invalid" }      ],      "scenes": [ { "heading": "EXT. SEA - DAY", "body": "Waves." } ],      "written": "Title:\n   THE INVENTED\n   LIGHTHOUSE\nContact: sample@example.invalid\n\nEXT. SEA - DAY\n\nWaves.\n"    },    {      "name": "an empty document has nothing",      "text": "",      "title_page": [],      "scenes": [],      "written": "\n"    }  ],  "lines": [    { "name": "a cue, its parenthetical and dialogue, then action after the blank",      "body": "TEO\n(reading)\nThe board thanks you.\n\nShe hands him the crank.",      "kinds": ["character", "parenthetical", "dialogue", "blank", "action"] },    { "name": "a capitals line with a blank under it is action, not a cue",      "body": "BANG\n\nThe door gives.",      "kinds": ["action", "blank", "action"] },    { "name": "a name just typed on the last line sets as a name, and so with the empty line being typed under it",      "body": "Waves.\n\nIRA\n",      "kinds": ["action", "blank", "character", "blank"] },    { "name": "a transition after a blank, a forced one, a centred line",      "body": "Waves.\n\nCUT TO:\n\n> FADE OUT.\n\n> THE END <",      "kinds": ["action", "blank", "transition", "blank", "transition", "blank", "centered"] },    { "name": "the writer's margin: section, synopsis, note, page break, lyric",      "body": "# Act one\n\n= Ira will not leave.\n\n[[check the tide tables]]\n\n===\n\n~Turn, turn, the lamp goes round",      "kinds": ["section", "blank", "synopsis", "blank", "note", "blank", "page_break", "blank", "lyric"] },    { "name": "forced action and a forced cue",      "body": "!SILENCE.\n\n@McCLANE\nYippee.",      "kinds": ["action", "blank", "character", "dialogue"] },    { "name": "a cue with an extension and a dual mark",      "body": "IRA (V.O.) ^\nTurn.",      "kinds": ["character", "dialogue"] },    { "name": "a heading inside a body still reads as one",      "body": "Waves.\n\nINT. LAMP ROOM - NIGHT\n\nDark.",      "kinds": ["action", "blank", "scene_heading", "blank", "action"] }  ],  "press": [    { "name": "Return after a cue: dialogue on the next line, no blank",      "body": "IRA", "caret": { "line": 0, "column": 3 }, "key": "return",      "want": { "body": "IRA\n", "caret": { "line": 1, "column": 0 }, "kind": "dialogue", "capitals": false } },    { "name": "Return after dialogue: a blank line, then action",      "body": "IRA\nTurn.", "caret": { "line": 1, "column": 5 }, "key": "return",      "want": { "body": "IRA\nTurn.\n\n", "caret": { "line": 3, "column": 0 }, "kind": "action", "capitals": false } },    { "name": "Return after a parenthetical: dialogue",      "body": "TEO\n(reading)", "caret": { "line": 1, "column": 9 }, "key": "return",      "want": { "body": "TEO\n(reading)\n", "caret": { "line": 2, "column": 0 }, "kind": "dialogue", "capitals": false } },    { "name": "Return after a transition: the next scene heading, in capitals",      "body": "Waves.\n\nCUT TO:", "caret": { "line": 2, "column": 7 }, "key": "return",      "want": { "body": "Waves.\n\nCUT TO:\n\n", "caret": { "line": 4, "column": 0 }, "kind": "scene_heading", "capitals": true } },    { "name": "Return after action: a blank line, then action",      "body": "Waves.", "caret": { "line": 0, "column": 6 }, "key": "return",      "want": { "body": "Waves.\n\n", "caret": { "line": 2, "column": 0 }, "kind": "action", "capitals": false } },    { "name": "Return mid-line splits it, the rest going to the new element",      "body": "Waves break.", "caret": { "line": 0, "column": 5 }, "key": "return",      "want": { "body": "Waves\n\n break.", "caret": { "line": 2, "column": 0 }, "kind": "action", "capitals": false } },    { "name": "Return on the empty line under dialogue leaves the speech for action",      "body": "IRA\nTurn.\n", "caret": { "line": 2, "column": 0 }, "key": "return",      "want": { "body": "IRA\nTurn.\n\n", "caret": { "line": 3, "column": 0 }, "kind": "action", "capitals": false } },    { "name": "Tab on an empty action line: a character, in capitals",      "body": "Waves.\n\n", "caret": { "line": 2, "column": 0 }, "key": "tab",      "want": { "body": "Waves.\n\n", "caret": { "line": 2, "column": 0 }, "kind": "character", "capitals": true } },    { "name": "Tab on an empty dialogue line: a parenthetical, the caret inside its brackets",      "body": "IRA\n", "caret": { "line": 1, "column": 0 }, "key": "tab",      "want": { "body": "IRA\n()", "caret": { "line": 1, "column": 1 }, "kind": "parenthetical", "capitals": false } },    { "name": "Tab on an empty parenthetical: back to dialogue",      "body": "IRA\n()", "caret": { "line": 1, "column": 1 }, "key": "tab",      "want": { "body": "IRA\n", "caret": { "line": 1, "column": 0 }, "kind": "dialogue", "capitals": false } },    { "name": "Tab under dialogue with words: a parenthetical line beneath",      "body": "IRA\nTurn.", "caret": { "line": 1, "column": 5 }, "key": "tab",      "want": { "body": "IRA\nTurn.\n()", "caret": { "line": 2, "column": 1 }, "kind": "parenthetical", "capitals": false } },    { "name": "Tab on an action line with words does nothing",      "body": "Waves.", "caret": { "line": 0, "column": 2 }, "key": "tab",      "want": { "body": "Waves.", "caret": { "line": 0, "column": 2 }, "kind": "action", "capitals": false } },    { "name": "a column is UTF-16: Return after an emoji splits after both its units",      "body": "Waves 🌊 break.", "caret": { "line": 0, "column": 8 }, "key": "return",      "want": { "body": "Waves 🌊\n\n break.", "caret": { "line": 2, "column": 0 }, "kind": "action", "capitals": false } }  ],  "headings": [    { "heading": "INT. KITCHEN - NIGHT", "want": { "setting": "INT", "place": "KITCHEN", "time": "NIGHT", "number": null } },    { "heading": "EXT. LIGHTHOUSE - LAMP ROOM - DUSK", "want": { "setting": "EXT", "place": "LIGHTHOUSE - LAMP ROOM", "time": "DUSK", "number": null } },    { "heading": "INT./EXT. CAR - MOVING", "want": { "setting": "INT/EXT", "place": "CAR", "time": "MOVING", "number": null } },    { "heading": "I/E HALLWAY", "want": { "setting": "INT/EXT", "place": "HALLWAY", "time": null, "number": null } },    { "heading": "est. harbour - dawn", "want": { "setting": "EST", "place": "harbour", "time": "dawn", "number": null } },    { "heading": ".THE ROOF", "want": { "setting": null, "place": "THE ROOF", "time": null, "number": null } },    { "heading": "INT. HALL - DAY #12A#", "want": { "setting": "INT", "place": "HALL", "time": "DAY", "number": "12A" } },    { "heading": "the kitchen, later", "want": { "setting": null, "place": "the kitchen, later", "time": null, "number": null } }  ],  "complete": [    { "typed": "i", "known": ["IRA", "Isolde", "TEO", "ira"], "want": ["IRA", "ISOLDE"] },    { "typed": "IRA", "known": ["IRA", "IRA'S MOTHER"], "want": ["IRA'S MOTHER"] },    { "typed": "@t", "known": ["TEO", "IRA"], "want": ["TEO"] },    { "typed": "", "known": ["TEO"], "want": [] }  ],  "pages": [    { "name": "three scenes on two pages", "lines": [30, 20, 40],      "want": { "pages": 2, "scenes": [ { "start": 1, "end": 1, "eighths": 4 }, { "start": 1, "end": 1, "eighths": 3 }, { "start": 1, "end": 2, "eighths": 6 } ] } },    { "name": "a scene that ends on a page's last line stays on it", "lines": [55, 1],      "want": { "pages": 2, "scenes": [ { "start": 1, "end": 1, "eighths": 8 }, { "start": 2, "end": 2, "eighths": 1 } ] } },    { "name": "an empty scene stands where the last left off", "lines": [0, 3],      "want": { "pages": 1, "scenes": [ { "start": 1, "end": 1, "eighths": 0 }, { "start": 1, "end": 1, "eighths": 1 } ] } },    { "name": "no scenes, no pages", "lines": [], "want": { "pages": 0, "scenes": [] } }  ]}