Comments (3)
Okay, PR #16 is up, which will hopefully fix this issue. Let me know if you see any problem with what I've outlined in the request / caveats above. If not, I'll review and merge it.
from fountain-js.
(deleted my earlier comment because I understood what the issue was, sorry for any confusion) 🤦♀️
It's the this.inlineLex.reconstruct()
method within to_html
that's mutating the shallow copy of the token objects. You're right that a deep copy is the way to go and I can fix this with a JSON round-trip; however, it presents some issues that I do want to make you aware of.
I assume you're using the parse
method to only retrieve the tokens and then are manipulating the tokens to render it into something else other than HTML, thus why having HTML embedded in the token text like <br />
is causing you issues. But I'm making some big assumptions here, so please correct me if I'm wrong.
The inlineLex.reconstruct()
method doesn't just work on newlines but is the inline lexer for all inline objects e.g. emphasis, underlines, etc. So what that means is that if I make this change, is that you'll have to perform your own inline lexing to convert these to whatever you want.
For example, given the action:
Murtaugh, springing hell bent for leather -- and folks,
grab your hats … because just then, a _BELL COBRA
HELICOPTER_ crests the edge of the bluff.
Where you want the helicopter name to be underlined, will yield the token:
[
ActionToken {
type: 'action',
text: 'Murtaugh, springing hell bent for leather -- and folks, \n' +
'grab your hats … because just then, a _BELL COBRA \n' +
'HELICOPTER_ crests the edge of the bluff.'
}
]
^^ e.g. the underline markup is still unchanged since inlineLex.reconstruct()
didn't mutate the text on the token. Also take note that this doesn't just happen in action but all tokens.
So, you'll probably have to run a version of your own inline lexer to solve this issue. I suggest using the code from the InlineLexer
class and just replace the html with whatever you want like <underline>$2</underline>
or whatever, but if you want something more complicated than strings like DOM or something then perhaps this won't work 🤔...
Anyway, thoughts are welcomed here. If this isn't an issue, I can push a fix for this.
from fountain-js.
Thanks for the additional context — and, of course, for the quick turnaround. I will update and test!
from fountain-js.
Related Issues (8)
- Question: Nesting dialog HOT 1
- Character names with hashes (#) are parsed incorrectly HOT 4
- Parentheticals can't be italicized HOT 6
- SyntaxError: Invalid regular expression: invalid group specifier name RegExp — rules.ts:23
- differences with mattdaly/Fountain.js HOT 3
- import { Fountain } from 'fountain' doesn't work HOT 6
- Doesn't seem to recognise `!` and `@` HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
inserted
from fountain-js.