Given the kind of fanboy I am of VSCode, I was like- lets see what is out there, and that's when I found your plugin, installed it immediately, and LOVED it.
Thanks for making this man. I look forward to sending some pull requests your way soon.
Here is the quick and dirty PHP I was on my way with before I found your plugin.
<?php
// Define various things a line could be.
define('MIN_VALUE', '0.0');
define('UNKNOWN_LINE_TYPE', 0);
define('EMPTY_LINE', 1);
define('SCENE_HEADING', 2);
define('CHARACTER', 3);
define('DIALOGUE', 4);
define('ACTION_LINE', 5);
define('TRANSITION', 6);
$code = [
'UNKNOWN_LINE_TYPE',
'EMPTY_LINE',
'SCENE_HEADING',
'CHARACTER',
'DIALOGUE',
'ACTION_LINE',
'TRANSITION',
];
$filepath = "/Users/sumeetpareek/github/[masked this part of the path]/main-draft.fountain";
$lines = file($filepath, FILE_IGNORE_NEW_LINES);
$line_type = [];
// Do not proceed if the first line is not empty.
if (!empty($lines[0])) {
die("First line of the input file must be an empty line.\n\n");
}
$line_type[0] = EMPTY_LINE;
// Iterate on every line to set their line_type.
for ($curr_line_num = 1; $curr_line_num < count($lines); $curr_line_num++) {
$curr_line = $lines[$curr_line_num];
if (empty($curr_line)) {
$line_type[$curr_line_num] = EMPTY_LINE;
continue;
}
if (substr($curr_line, 0, 1) === "." || substr($curr_line, 0, 3) === "EXT" || substr($curr_line, 0, 3) === "INT") {
$line_type[$curr_line_num] = SCENE_HEADING;
continue;
}
if (substr($curr_line, 0, 2) === "> " || (strtoupper($curr_line) == $curr_line && substr($curr_line, -1) == ":")) {
$line_type[$curr_line_num] = TRANSITION;
continue;
}
if (strtoupper($curr_line) == $curr_line) {
$line_type[$curr_line_num] = CHARACTER;
continue;
}
if ($line_type[$curr_line_num - 1] == CHARACTER) {
$line_type[$curr_line_num] = DIALOGUE;
continue;
}
// Or if none of those then it is an action line.
$line_type[$curr_line_num] = ACTION_LINE;
}
// Print every line_type and line.
for ($curr_line_num = 0; $curr_line_num < count($lines); $curr_line_num++) {
$key = $line_type[$curr_line_num];
print "\n(( $code[$key] )) ". $lines[$curr_line_num];
}