From 4fc8f3f35c959f25a3e0c184d11a5a0c5b23037b Mon Sep 17 00:00:00 2001 From: Andy Buchholz Date: Sun, 5 Apr 2015 14:26:34 +0200 Subject: [PATCH] allow all chars in character name --- fountain.js | 36 ++++++++++++++++++------------------ fountain.min.js | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fountain.js b/fountain.js index b614e1d..89d88af 100644 --- a/fountain.js +++ b/fountain.js @@ -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: /^(?:\=(?!\=+) *)(.*)/, @@ -50,7 +50,7 @@ .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 @@ -58,7 +58,7 @@ 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(); @@ -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) { @@ -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) { @@ -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] }); @@ -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' }); @@ -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; @@ -197,7 +197,7 @@ while (i--) { style = styles[i]; match = regex[style]; - + if (match.test(s)) { s = s.replace(match, inline[style]); } @@ -212,7 +212,7 @@ callback = toks; toks = undefined; } - + var tokens = tokenize(script) , i = tokens.length, token , title, title_page = [], html = [], output; @@ -253,7 +253,7 @@ case 'action': html.push('

' + token.text + '

'); break; case 'centered': html.push('

' + token.text + '

'); break; - + case 'page_break': html.push('
'); break; case 'line_break': html.push('
'); break; } @@ -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); }; @@ -280,5 +280,5 @@ module.exports = fountain; } else { this.fountain = fountain; - } + } }).call(this); diff --git a/fountain.min.js b/fountain.min.js index 3402949..50422b8 100644 --- a/fountain.min.js +++ b/fountain.min.js @@ -1,4 +1,4 @@ -(function(){var d={title_page:/^((?:title|credit|author[s]?|source|notes|draft date|date|contact|copyright)\:)/gim,scene_heading:/^((?:\*{0,3}_?)?(?:(?:int|ext|est|i\/e)[. ]).+)|^(?:\.(?!\.+))(.+)/i,scene_number:/( *#(.+)# *)/,transition:/^((?:FADE (?:TO BLACK|OUT)|CUT TO BLACK)\.|.+ TO\:)|^(?:> *)(.+)/,dialogue:/^([A-Z*_]+[0-9A-Z (._\-')]*)(\^?)?(?:\n(?!\n+))([\s\S]+)/,parenthetical:/^(\(.+\))$/,action:/^(.+)/g,centered:/^(?:> *)(.+)(?: *<)(\n.+)*/g,section:/^(#+)(?: *)(.*)/,synopsis:/^(?:\=(?!\=+) *)(.*)/, +(function(){var d={title_page:/^((?:title|credit|author[s]?|source|notes|draft date|date|contact|copyright)\:)/gim,scene_heading:/^((?:\*{0,3}_?)?(?:(?:int|ext|est|i\/e)[. ]).+)|^(?:\.(?!\.+))(.+)/i,scene_number:/( *#(.+)# *)/,transition:/^((?:FADE (?:TO BLACK|OUT)|CUT TO BLACK)\.|.+ TO\:)|^(?:> *)(.+)/,dialogue:/^([A-Z\u00C0-\u017F*_]+[0-9A-Z (._\-')]*)(\^?)?(?:\n(?!\n+))([\s\S]+)/,parenthetical:/^(\(.+\))$/,action:/^(.+)/g,centered:/^(?:> *)(.+)(?: *<)(\n.+)*/g,section:/^(#+)(?: *)(.*)/,synopsis:/^(?:\=(?!\=+) *)(.*)/, note:/^(?:\[{2}(?!\[+))(.+)(?:\]{2}(?!\[+))$/,note_inline:/(?:\[{2}(?!\[+))([\s\S]+?)(?:\]{2}(?!\[+))/g,boneyard:/(^\/\*|^\*\/)$/g,page_break:/^\={3,}$/,line_break:/^ {2}$/,emphasis:/(_|\*{1,3}|_\*{1,3}|\*{1,3}_)(.+)(_|\*{1,3}|_\*{1,3}|\*{1,3}_)/g,bold_italic_underline:/(_{1}\*{3}(?=.+\*{3}_{1})|\*{3}_{1}(?=.+_{1}\*{3}))(.+?)(\*{3}_{1}|_{1}\*{3})/g,bold_underline:/(_{1}\*{2}(?=.+\*{2}_{1})|\*{2}_{1}(?=.+_{1}\*{2}))(.+?)(\*{2}_{1}|_{1}\*{2})/g,italic_underline:/(?:_{1}\*{1}(?=.+\*{1}_{1})|\*{1}_{1}(?=.+_{1}\*{1}))(.+?)(\*{1}_{1}|_{1}\*{1})/g, bold_italic:/(\*{3}(?=.+\*{3}))(.+?)(\*{3})/g,bold:/(\*{2}(?=.+\*{2}))(.+?)(\*{2})/g,italic:/(\*{1}(?=.+\*{1}))(.+?)(\*{1})/g,underline:/(_{1}(?=.+_{1}))(.+?)(_{1})/g,splitter:/\n{2,}/g,cleaner:/^\n+|\n+$/,standardizer:/\r\n|\r/g,whitespacer:/^\t+|^ {3,}/gm},n={note:"<\!-- $1 --\>",line_break:"
",bold_italic_underline:'$2',bold_underline:'$2',italic_underline:'$2',bold_italic:'$2', bold:'$2',italic:'$2',underline:'$2',lexer:function(c){if(c){for(var j="underline,italic,bold,bold_italic,italic_underline,bold_underline,bold_italic_underline".split(","),k=j.length,g,b,c=c.replace(d.note_inline,n.note).replace(/\\\*/g,"[star]").replace(/\\_/g,"[underline]").replace(/\n/g,n.line_break);k--;)g=j[k],b=d[g],b.test(c)&&(c=c.replace(b,n[g]));return c.replace(/\[star\]/g,"*").replace(/\[underline\]/g, @@ -9,4 +9,4 @@ c.push({type:"note",text:a[1]}):(a=e.match(d.boneyard))?c.push({type:"/"===a[0][ b.text+"

");break;case "authors":f.push('

'+b.text+"

");break;case "source":f.push('

'+b.text+"

");break;case "notes":f.push('

'+b.text+"

");break;case "draft_date":f.push('

'+b.text+"

");break;case "date":f.push('

'+b.text+"

");break;case "contact":f.push('

'+b.text+"

");break;case "copyright":f.push('");break;case "scene_heading":a.push("':">")+b.text+"");break;case "transition":a.push("

"+b.text+"

");break;case "dual_dialogue_begin":a.push('
');break;case "dialogue_begin":a.push('
');break;case "character":a.push("

"+b.text+"

");break;case "parenthetical":a.push('

'+b.text+"

");break;case "dialogue":a.push("

"+b.text+"

");break;case "dialogue_end":a.push("
"); break;case "dual_dialogue_end":a.push("
");break;case "section":a.push('

'+b.text+"

");break;case "synopsis":a.push('

'+b.text+"

");break;case "note":a.push("<\!-- "+b.text+"--\>");break;case "boneyard_begin":a.push("<\!-- ");break;case "boneyard_end":a.push(" --\>");break;case "action":a.push("

"+b.text+"

");break;case "centered":a.push('

'+b.text+"

");break;case "page_break":a.push("
");break; -case "line_break":a.push("
")}g={title:g,html:{title_page:f.join(""),script:a.join("")},tokens:j?c.reverse():void 0};g="function"===typeof k?k(g):g;return g};"undefined"!==typeof module?module.exports=h:this.fountain=h}).call(this); \ No newline at end of file +case "line_break":a.push("
")}g={title:g,html:{title_page:f.join(""),script:a.join("")},tokens:j?c.reverse():void 0};g="function"===typeof k?k(g):g;return g};"undefined"!==typeof module?module.exports=h:this.fountain=h}).call(this);