Skip to content

Instantly share code, notes, and snippets.

@videlais
Created June 20, 2019 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlais/3c4346360c59e2a59074320c06a1cbd2 to your computer and use it in GitHub Desktop.
Save videlais/3c4346360c59e2a59074320c06a1cbd2 to your computer and use it in GitHub Desktop.
// Check if there are extra content in the files
// If so, cut it all out for the parser
if(fileContents[0] != ':' && fileContents[1] != ':') {
let firstPassagePos = fileContents.indexOf('::');
fileContents = fileContents.slice(firstPassagePos, fileContents.length);
}
// Split the file based on the passage sigil (::) preceeded by a newline
let parsingPassages = fileContents.split('\n::');
// Check if any passages exist
if(parsingPassages == 0) {
throw new Error("No passages were found!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment