Giter VIP home page Giter VIP logo

fountain-js's Issues

Action with a newline gets a <br /> inserted

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,
      };

Parentheticals can't be italicized

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!

Character names with hashes (#) are parsed incorrectly

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!

import { Fountain } from 'fountain' doesn't work

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:

Doesn't seem to recognise `!` and `@`

! 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.

Question: Nesting dialog

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.