Skip to content

Commit

Permalink
allow all chars in character name
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Buchholz committed Apr 5, 2015
1 parent ab7f539 commit 4fc8f3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions fountain.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
scene_number: /( *#(.+)# *)/,

transition: /^((?:FADE (?:TO BLACK|OUT)|CUT TO BLACK)\.|.+ TO\:)|^(?:> *)(.+)/,
dialogue: /^([A-Z*_]+[0-9A-Z (._\-')]*)(\^?)?(?:\n(?!\n+))([\s\S]+)/,

dialogue: /^([A-Z\u00C0-\u017F*_]+[0-9A-Z (._\-')]*)(\^?)?(?:\n(?!\n+))([\s\S]+)/,
parenthetical: /^(\(.+\))$/,

action: /^(.+)/g,
centered: /^(?:> *)(.+)(?: *<)(\n.+)*/g,

section: /^(#+)(?: *)(.*)/,
synopsis: /^(?:\=(?!\=+) *)(.*)/,

Expand Down Expand Up @@ -50,15 +50,15 @@
.replace(regex.cleaner, '')
.replace(regex.whitespacer, '');
};

var tokenize = function (script) {
var src = lexer(script).split(regex.splitter)
, i = src.length, line, match, parts, text, meta, x, xlen, dual
, tokens = [];

while (i--) {
line = src[i];

// title page
if (regex.title_page.test(line)) {
match = line.replace(regex.title_page, '\n$1').split(regex.splitter).reverse();
Expand Down Expand Up @@ -94,7 +94,7 @@
tokens.push({ type: 'transition', text: match[1] || match[2] });
continue;
}

// dialogue blocks - characters, parentheticals and dialogue
if (match = line.match(regex.dialogue)) {
if (match[1].indexOf(' ') !== match[1].length - 2) {
Expand All @@ -107,7 +107,7 @@

parts = match[3].split(/(\(.+\))(?:\n+)/).reverse();

for (x = 0, xlen = parts.length; x < xlen; x++) {
for (x = 0, xlen = parts.length; x < xlen; x++) {
text = parts[x];

if (text.length > 0) {
Expand All @@ -126,13 +126,13 @@
continue;
}
}

// section
if (match = line.match(regex.section)) {
tokens.push({ type: 'section', text: match[2], depth: match[1].length });
continue;
}

// synopsis
if (match = line.match(regex.synopsis)) {
tokens.push({ type: 'synopsis', text: match[1] });
Expand All @@ -143,20 +143,20 @@
if (match = line.match(regex.note)) {
tokens.push({ type: 'note', text: match[1]});
continue;
}
}

// boneyard
if (match = line.match(regex.boneyard)) {
tokens.push({ type: match[0][0] === '/' ? 'boneyard_begin' : 'boneyard_end' });
continue;
}
}

// page breaks
if (regex.page_break.test(line)) {
tokens.push({ type: 'page_break' });
continue;
}

// line breaks
if (regex.line_break.test(line)) {
tokens.push({ type: 'line_break' });
Expand Down Expand Up @@ -186,7 +186,7 @@
inline.lexer = function (s) {
if (!s) {
return;
}
}

var styles = [ 'underline', 'italic', 'bold', 'bold_italic', 'italic_underline', 'bold_underline', 'bold_italic_underline' ]
, i = styles.length, style, match;
Expand All @@ -197,7 +197,7 @@
while (i--) {
style = styles[i];
match = regex[style];

if (match.test(s)) {
s = s.replace(match, inline[style]);
}
Expand All @@ -212,7 +212,7 @@
callback = toks;
toks = undefined;
}

var tokens = tokenize(script)
, i = tokens.length, token
, title, title_page = [], html = [], output;
Expand Down Expand Up @@ -253,7 +253,7 @@

case 'action': html.push('<p>' + token.text + '</p>'); break;
case 'centered': html.push('<p class=\"centered\">' + token.text + '</p>'); break;

case 'page_break': html.push('<hr />'); break;
case 'line_break': html.push('<br />'); break;
}
Expand All @@ -271,7 +271,7 @@
var fountain = function (script, callback) {
return fountain.parse(script, callback);
};

fountain.parse = function (script, tokens, callback) {
return parse(script, tokens, callback);
};
Expand All @@ -280,5 +280,5 @@
module.exports = fountain;
} else {
this.fountain = fountain;
}
}
}).call(this);
4 changes: 2 additions & 2 deletions fountain.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4fc8f3f

Please sign in to comment.