wiki_thsf_2015/public/js/textile.min.js

1 line
20 KiB
JavaScript
Raw Normal View History

2015-03-29 06:13:18 +11:00
(function(){"use strict";var re={_cache:{},pattern:{punct:"[!-/:-@\\[\\\\\\]-`{-~]",space:"\\s"},escape:function(src){return src.replace(/[\-\[\]\{\}\(\)\*\+\?\.\,\\\^\$\|\#\s]/g,"\\$&")},collapse:function(src){return src.replace(/(?:#.*?(?:\n|$))/g,"").replace(/\s+/g,"")},expand_patterns:function(src){return src.replace(/\[\:\s*(\w+)\s*\:\]/g,function(m,k){return k in re.pattern?re.expand_patterns(re.pattern[k]):k})},isRegExp:function(r){return Object.prototype.toString.call(r)==="[object RegExp]"},compile:function(src,flags){if(re.isRegExp(src)){if(arguments.length===1){flags=(src.global?"g":"")+(src.ignoreCase?"i":"")+(src.multiline?"m":"")}src=src.source}var ckey=src+(flags||"");if(ckey in re._cache){return re._cache[ckey]}var rx=re.expand_patterns(src);if(flags&&/x/.test(flags)){rx=re.collapse(rx)}if(flags&&/s/.test(flags)){rx=rx.replace(/([^\\])\./g,"$1[^\\0]")}flags=(flags||"").replace(/[^gim]/g,"");return re._cache[ckey]=new RegExp(rx,flags)}};var JSONML={escape:function(text,esc_quotes){return text.replace(/&(?!(#\d{2,}|#x[\da-fA-F]{2,}|[a-zA-Z][a-zA-Z1-4]{1,6});)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,esc_quotes?"&quot;":'"').replace(/'/g,esc_quotes?"&#39;":"'")},toHTML:function(jsonml){jsonml=jsonml.concat();if(typeof jsonml==="string"){return JSONML.escape(jsonml)}var tag=jsonml.shift(),attributes={},content=[],tag_attrs="",a;if(jsonml.length&&typeof jsonml[0]==="object"&&!_isArray(jsonml[0])){attributes=jsonml.shift()}while(jsonml.length){content.push(JSONML.toHTML(jsonml.shift()))}for(a in attributes){tag_attrs+=attributes[a]==null?" "+a:" "+a+'="'+JSONML.escape(attributes[a],true)+'"'}if(tag=="!"){return"<!--"+content.join("")+"-->"}else if(tag==="img"||tag==="br"||tag==="hr"||tag==="input"){return"<"+tag+tag_attrs+" />"}else{return"<"+tag+tag_attrs+">"+content.join("")+"</"+tag+">"}}};function merge(a,b){for(var k in b){a[k]=b[k]}return a}var _isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"};re.pattern["blocks"]="(?:b[qc]|div|notextile|pre|h[1-6]|fn\\d+|p|###)";re.pattern["pba_class"]="\\([^\\)]+\\)";re.pattern["pba_style"]="\\{[^\\}]+\\}";re.pattern["pba_lang"]="\\[[^\\[\\]]+\\]";re.pattern["pba_align"]="(?:<>|<|>|=)";re.pattern["pba_pad"]="[\\(\\)]+";re.pattern["pba_attr"]="(?:[:pba_class:]|[:pba_style:]|[:pba_lang:]|[:pba_align:]|[:pba_pad:])*";re.pattern["url_punct"]="[.,«»″‹›!?]";re.pattern["html_id"]="[a-zA-Z][a-zA-Z\\d:]*";re.pattern["html_attr"]="(?:\"[^\"]+\"|'[^']+'|[^>\\s]+)";re.pattern["tx_urlch"]='[\\w"$\\-_.+!*\'(),";\\/?:@=&%#{}|\\\\^~\\[\\]`]';re.pattern["tx_cite"]=":((?:[^\\s()]|\\([^\\s()]+\\)|[()])+?)(?=[!-\\.:-@\\[\\\\\\]-`{-~]+(?:$|\\s)|$|\\s)";re.pattern["ucaps"]="A-Z"+"À-ÖØ-Þ"+"ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿ"+"ŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸŹŻŽ"+"ƁƂƄƆƇƉ-ƋƎ-ƑƓƔƖ-ƘƜƝƟƠƢƤƦƧƩƬƮƯƱ-ƳƵƷƸƼ"+"DŽLJNJǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZǴǶ-ǸǺǼǾ"+"ȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺȻȽȾ"+"ɁɃ-ɆɈɊɌɎ"+"ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀ"+"ṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾ"+"ẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾ"+"ỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾ"+"ⱠⱢ-ⱤⱧⱩⱫⱭ-ⱰⱲⱵⱾⱿ"+"ꜢꜤꜦꜨꜪꜬꜮꜲꜴꜶꜸꜺꜼꜾ"+"ꝀꝂꝄꝆꝈꝊꝌꝎꝐꝒꝔꝖꝘꝚꝜꝞꝠꝢꝤꝦꝨꝪꝬꝮꝹꝻꝽꝾ"+"ꞀꞂꞄꞆꞋꞍꞐꞒꞠꞢꞤꞦꞨꞪ";var re_block=re.compile(/^([:blocks:])/),re_block_se=re.compile(/^[:blocks:]$/),re_block_normal=re.compile(/^(.*?)($|\n(?:\s*\n|$)+)/,"s"),re_block_extended=re.compile(/^(.*?)($|\n+(?=[:blocks:][:pba_attr:]\.))/,"s"),re_ruler=/^(\-\-\-+|\*\*\*+|___+)(\n\s+|$)/,re_list=re.compile(/^((?:[\t ]*[\#\*]+[:pba_attr:] .+?(?:\n|$))+)(\s*\n)?/),re_list_item=/^([\#\*]+)(.+?)(\n|$)/,re_table=re.compile(/^((?:tabl