jonnygreenwald / fountain-js Goto Github PK
View Code? Open in Web Editor NEWA simple parser for Fountain, a markup language for formatting screenplays.
License: MIT License
A simple parser for Fountain, a markup language for formatting screenplays.
License: MIT License
If you have a line of action with a newline (\n), it gets replaced with a <br />
.
The problem seems to come from passing this.tokens
into to_html()
. If, instead, you make a deep copy (so that to_html()
doesn't modify the instance), it works as expected. For example:
const tokenCopy = Utils.deepCopy(this.tokens) as Token[];
return {
title: titleString,
html: {
title_page: tokenCopy
.filter(token => token.is_title)
.map(token => this.to_html(token))
.join(''),
script: tokenCopy
.filter(token => !token.is_title)
.map(token => this.to_html(token))
.join(''),
},
tokens: getTokens ? this.tokens : undefined,
};
If a parenthetical is italicized, it won't match the parenthetical regular expression. I've seen scripts where writers will italicize the odd parenthetical. If you want to add support, here's an updated regular expression for token.ts
.
const parts: string[] = match[3].split(/(\*?\(.+\)\*?)(?:\n+)/).reverse();
Thanks!
First, thanks so much maintaining this project. I works very well, and has saved me a ton of time.
I think I found a bug related to CHARACTER NAMES with hashes (#). Specifically, this:
DISGRUNTLED CITIZEN #1
(standing)
Excuse me. How much did it cost?
Gets tokenized like this:
{
"type": "action",
"text": "DISGRUNTLED CITIZEN #1<br />(standing)<br />Excuse me. How much did it cost?"
}
(I've verified with a few different instances.)
Is this an invalid Fountain character name, or a bug? Thanks!
I ran npm install fountain
and then import { Fountain } from 'fountain'
[plugin vite:dep-scan] Failed to resolve entry for package "fountain". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "fountain". The package may have incorrect main/module/exports specified in its package.json.
node_modules/vite/dist/node/chunks/dep-9c153816.js:29537:10:
29537 │ throw new Error(`Failed to resolve entry for package "${id}". ` +
╵ ^
at packageEntryFailure (/Users/pj/software/petersir/sveltekit/node_modules/vite/dist/node/chunks/dep-9c153816.js:29537:11)
at resolvePackageEntry (/Users/pj/software/petersir/sveltekit/node_modules/vite/dist/node/chunks/dep-9c153816.js:29533:9)
at tryNodeResolve (/Users/pj/software/petersir/sveltekit/node_modules/vite/dist/node/chunks/dep-9c153816.js:29349:20)
at Context.resolveId (/Users/pj/software/petersir/sveltekit/node_modules/vite/dist/node/chunks/dep-9c153816.js:29166:28)
at Object.resolveId (/Users/pj/software/petersir/sveltekit/node_modules/vite/dist/node/chunks/dep-9c153816.js:38271:55)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async resolve (/Users/pj/software/petersir/sveltekit/node_modules/vite/dist/node/chunks/dep-9c153816.js:38474:26)
at async /Users/pj/software/petersir/sveltekit/node_modules/vite/dist/node/chunks/dep-9c153816.js:38612:34
at async callback (/Users/pj/software/petersir/sveltekit/node_modules/esbuild/lib/main.js:917:28)
at async handleRequest (/Users/pj/software/petersir/sveltekit/node_modules/esbuild/lib/main.js:697:30)
This error came from the "onResolve" callback registered here:
!
can be used to symbolise a definite action.
@
can be used to symbolise a definite character name for the dialogue.
It seems to group @
as Action instead.
Maybe the original library was made before the !
and @
were added to the specs.
Running into this issue when trying to load fountain-js in Tauri / WebView
Is there any reason why dialog_begin
and dialog_end
couldn't be
{
type: "dialog",
lines: [
{ character: "Jen", line: "Nice to meet you" },
...
]
}
Seems like it'd make parsing a bit easier. I'm using this in React, and needing a way to replace string matches with react components and finding these tokens a little hard to work with.
If it's helpful or wanted I can help code
I was wondering what the differences are with mattdaly/Fountain.js?
Is this more robust in terms of interpreting or less error prone?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.