diff --git a/modules/wiky.css b/modules/wiky.css new file mode 100755 index 0000000..062f34e --- /dev/null +++ b/modules/wiky.css @@ -0,0 +1,15 @@ +/* == wiky == */ +*.wiki blockquote { background:#ddd; border:solid 1px #999; margin-left:1em; padding:0.5em;} +*.wiki table { + border-collapse: collapse; + empty-cells: show; +} + +*.wiki table td { + border: solid 1px black; + padding: 0.25em 0.5em 0.25em 0.5em; + text-align: center; +} + +/*pre { font-size:100%; background: #eed; border:1px dotted #999; padding:0 0.5em; overflow:auto; }*/ +pre { font-family:courier new, monospace; overflow:auto; } diff --git a/modules/wiky.js b/modules/wiky.js new file mode 100755 index 0000000..71e46ff --- /dev/null +++ b/modules/wiky.js @@ -0,0 +1,373 @@ +/* This work is licensed under Creative Commons GNU LGPL License. + + License: http://creativecommons.org/licenses/LGPL/2.1/ + + Author: Stefan Goessner/2005-06 + Web: http://goessner.net/ +*/ +var Wiky = { + version: 0.95, + blocks: null, + rules: { + all: [ + "Wiky.rules.pre", + "Wiky.rules.nonwikiblocks", + "Wiky.rules.wikiblocks", + "Wiky.rules.post", + ], + pre: [ + { rex:/(\r?\n)/g, tmplt:"\xB6" }, // replace line breaks with '¶' .. + ], + post: [ + { rex:/(^\xB6)|(\xB6$)/g, tmplt:"" }, // .. remove linebreaks at BOS and EOS .. + { rex:/@([0-9]+)@/g, tmplt:function($0,$1){return Wiky.restore($1);} }, // resolve blocks .. + { rex:/\xB6/g, tmplt:"\n" } // replace '¶' with line breaks .. + ], + nonwikiblocks: [ + { rex:/\\([%])/g, tmplt:function($0,$1){return Wiky.store($1);} }, + { rex:/\[(?:\{([^}]*)\})?(?:\(([^)]*)\))?%(.*?)%\]/g, tmplt:function($0,$1,$2,$3){return ":p]"+Wiky.store("
" + Wiky.apply($3, $2?Wiky.rules.lang[Wiky.attr($2)]:Wiky.rules.code) + "
")+"[p:";} } //programm code block
+ ],
+ wikiblocks: [
+ "Wiky.rules.nonwikiinlines",
+ "Wiky.rules.escapes",
+ { rex:/(?:^|\xB6)(={1,6})(.*?)[=]*(?=\xB6|$)/g, tmplt:function($0,$1,$2){ var h=$1.length; return ":p]\xB6[p:"; } }, // block quotation start + { rex:/\"\]/g, tmplt:":p][p:" }, // block quotation end + { rex:/\[(\{[^}]*\})?\|/g, tmplt:":t]$1[r:" }, // .. start table .. + { rex:/\|\]/g, tmplt:":r][t:" }, // .. end table .. + { rex:/\|\xB6[ ]?\|/g, tmplt:":r]\xB6[r:" }, // .. end/start table row .. + { rex:/\|/g, tmplt:":c][c:" }, // .. end/start table cell .. + { rex:/^(.*)$/g, tmplt:"[p:$1:p]" }, // start paragraph '[p:' at BOS .. end paragraph ':p]' at EOS .. + { rex:/(([\xB6])([ \t\f\v\xB6]*?)){2,}/g, tmplt:":p]$1[p:" }, // .. separate paragraphs at blank lines .. + { rex:/\[([01AIacdgilprtu]+)[:](.*?)[:]([01AIacdgilprtu]+)\]/g, tmplt:function($0,$1,$2,$3){return Wiky.sectionRule($1==undefined?"":$1,"",Wiky.apply($2,Wiky.rules.wikiinlines),!$3?"":$3);} }, + { rex:/\[[01AIacdgilprtu]+[:]|[:][01AIacdgilprtu]+\]/g, tmplt:"" }, // .. remove singular section delimiters (they frequently exist with incomplete documents while typing) .. + { rex:/
([ \t\f\v\xB6]*?)<\/p>/g, tmplt:"$1" }, // .. remove empty paragraphs ..
+ "Wiky.rules.shortcuts"
+ ],
+ nonwikiinlines: [
+ { rex:/%(?:\{([^}]*)\})?(?:\(([^)]*)\))?(.*?)%/g, tmplt:function($0,$1,$2,$3){return Wiky.store("" + Wiky.apply($3, $2?Wiky.rules.lang[Wiky.attr($2)]:Wiky.rules.code) + "
");} }, // inline code
+ { rex:/%(.*?)%/g, tmplt:function($0,$1){return Wiky.store("" + Wiky.apply($2, Wiky.rules.code) + "
");} }
+ ],
+ wikiinlines: [
+ { rex:/\*([^*]+)\*/g, tmplt:"$1" }, // .. strong ..
+ { rex:/_([^_]+)_/g, tmplt:"$1" },
+ { rex:/\^([^^]+)\^/g, tmplt:"$1" },
+ { rex:/~([^~]+)~/g, tmplt:"$1" },
+ { rex:/\(-(.+?)-\)/g, tmplt:"$1" },
+ { rex:/\?([^ \t\f\v\xB6]+)\((.+)\)\?/g, tmplt:"$1" }, // .. abbreviation ..
+ { rex:/\[(?:\{([^}]*)\})?[Ii]ma?ge?\:([^ ,\]]*)(?:[, ]([^\]]*))?\]/g, tmplt:function($0,$1,$2,$3){return Wiky.store("");} }, // wikimedia image style ..
+ { rex:/\[([^ ,]+)[, ]([^\]]*)\]/g, tmplt:function($0,$1,$2){return Wiky.store(""+$2+"");}}, // wiki block style uri's ..
+ { rex:/(((http(s?))\:\/\/)?[A-Za-z0-9\._\/~\-:]+\.(?:png|jpg|jpeg|gif|bmp))/g, tmplt:function($0,$1,$2){return Wiky.store("
");} }, // simple images ..
+ { rex:/((mailto\:|javascript\:|(news|file|(ht|f)tp(s?))\:\/\/)[A-Za-z0-9\.:_\/~%\-+?!=()@\x80-\xB5\xB7\xFF]+)/g, tmplt:"$1" } // simple uri's ..
+ ],
+ escapes: [
+ { rex:/\\([|*_~\^])/g, tmplt:function($0,$1){return Wiky.store($1);} },
+ { rex:/\\&/g, tmplt:"&" },
+ { rex:/\\>/g, tmplt:">" },
+ { rex:/\\/g, tmplt:"↔"}, // $harr;
+ { rex:/<-/g, tmplt:"←"}, // ←
+ { rex:/->/g, tmplt:"→"}, //→
+ ],
+ code: [
+ { rex:/&/g, tmplt:"&"},
+ { rex://g, tmplt:">"}
+ ],
+ lang: {}
+ },
+
+ inverse: {
+ all: [
+ "Wiky.inverse.pre",
+ "Wiky.inverse.nonwikiblocks",
+ "Wiky.inverse.wikiblocks",
+ "Wiky.inverse.post"
+ ],
+ pre: [
+ { rex:/(\r?\n)/g, tmplt:"\xB6" } // replace line breaks with '¶' ..
+ ],
+ post: [
+ { rex:/@([0-9]+)@/g, tmplt:function($0,$1){return Wiky.restore($1);} }, // resolve blocks ..
+ { rex:/\xB6/g, tmplt:"\n" } // replace '¶' with line breaks ..
+ ],
+ nonwikiblocks: [
+ { rex:/
]*)>(.*?)<\/pre>/mgi, tmplt:function($0,$1,$2){return Wiky.store("["+Wiky.invStyle($1)+Wiky.invAttr($1,["lang"]).replace(/x\-/,"")+"%"+Wiky.apply($2, Wiky.hasAttr($1,"lang")?Wiky.inverse.lang[Wiky.attrVal($1,"lang").substr(2)]:Wiky.inverse.code)+"%]");} } //code block + ], + wikiblocks: [ + "Wiky.inverse.nonwikiinlines", + "Wiky.inverse.escapes", + "Wiky.inverse.wikiinlines", + { rex:/(.*?)<\/h1>/mgi, tmplt:"=$1=" }, + { rex:/
(.*?)<\/h2>/mgi, tmplt:"==$1==" }, + { rex:/
(.*?)<\/h3>/mgi, tmplt:"===$1===" }, + { rex:/
(.*?)<\/h4>/mgi, tmplt:"====$1====" }, + { rex:/
(.*?)<\/h5>/mgi, tmplt:"=====$1=====" }, + { rex:/
(.*?)<\/h6>/mgi, tmplt:"======$1======" }, + { rex:/<(p|table)[^>]+(style=\"[^\"]*\")[^>]*>/mgi, tmplt:function($0,$1,$2){return "<"+$1+">"+Wiky.invStyle($2);} }, + { rex:/\xB6{2}
]*)>/mgi, tmplt:function($0,$1){return Wiky.store("["+Wiky.invStyle($1)+Wiky.invAttr($1,["cite","title"])+"\"");} }, + { rex:/<\/blockquote>/mgi, tmplt:"\"]" }, + { rex:/\xB6*[ ]?|<\/tr>/mgi, tmplt:"|" }, // ie6 only .. + { rex:/\xB6 ]*?)>/mgi, tmplt:"\xB6" }, + { rex:/ ]*?)>/mgi, tmplt:"|$1>" }, + { rex:/ ]*?)>/mgi, tmplt:"|" }, + { rex:/ /mgi, tmplt:"[" }, + { rex:/<\/table>/mgi, tmplt:"]" }, + { rex:/
]*?)>\xB6*|<\/td>\xB6*| \xB6*|<\/tbody>/mgi, tmplt:"" }, + { rex:/
/mgi, tmplt:"----" }, + { rex:/
/mgi, tmplt:"\\\\" }, + { rex:/(|<(d|o|u)l[^>]*>|<\/(dl|ol|ul|p)>|<\/(li|dd)>)/mgi, tmplt:"" }, + "Wiky.inverse.shortcuts" + ], + nonwikiinlines: [ + { rex:/
(.*?)<\/code>/g, tmplt:function($0,$1){return Wiky.store("%"+Wiky.apply($1, Wiky.inverse["code"])+"%");} } + ], + wikiinlines: [ + { rex:/]*?>(.*?)<\/strong>/mgi, tmplt:"*$1*" }, + { rex:/]*?>(.*?)<\/b>/mgi, tmplt:"*$1*" }, + { rex:/]*?>(.*?)<\/em>/mgi, tmplt:"_$1_" }, + { rex:/]*?>(.*?)<\/i>/mgi, tmplt:"_$1_" }, + { rex:/]*?>(.*?)<\/sup>/mgi, tmplt:"^$1^" }, + { rex:/]*?>(.*?)<\/sub>/mgi, tmplt:"~$1~" }, + { rex:/
]*?>(.*?)<\/del>/mgi, tmplt:"(-$1-)" }, + { rex:/(.*?)<\/abbr>/mgi, tmplt:"?$2($1)?" }, + { rex:/]*?>(.*?)<\/a>/mgi, tmplt:function($0,$1,$2){return $1==$2?$1:"["+$1+","+$2+"]";}}, + { rex:/]*)\/>/mgi, tmplt:function($0,$1){var a=Wiky.attrVal($1,"alt"),h=Wiky.attrVal($1,"src"),t=Wiky.attrVal($1,"title"),s=Wiky.attrVal($1,"style");return s||(t&&h!=t)?("["+Wiky.invStyle($1)+"img:"+h+(t&&(","+t))+"]"):h;}}, + ], + escapes: [ + { rex:/([|*_~%\^])/g, tmplt:"\\$1" }, + { rex:/&/g, tmplt:"\\&" }, + { rex:/>/g, tmplt:"\\>" }, + { rex:/</g, tmplt:"\\<" } + ], + shortcuts: [ + { rex:/–|\u2013/g, tmplt:"--"}, + { rex:/—|\u2014/g, tmplt:"---"}, + { rex:/…|\u2026/g, tmplt:"..."}, + { rex:/↔|\u2194/g, tmplt:"<->"}, + { rex:/←|\u2190/g, tmplt:"<-"}, + { rex:/→|\u2192/g, tmplt:"->"} + ], + code: [ + { rex:/&/g, tmplt:"&"}, + { rex:/</g, tmplt:"<"}, + { rex:/>/g, tmplt:">"} + ], + lang: {} + }, + + toHtml: function(str) { + Wiky.blocks = []; + return Wiky.apply(str, Wiky.rules.all); + }, + + toWiki: function(str) { + Wiky.blocks = []; + return Wiky.apply(str, Wiky.inverse.all); + }, + + apply: function(str, rules) { + if (str && rules) + for (var i in rules) { + if (typeof(rules[i]) == "string") + str = Wiky.apply(str, eval(rules[i])); + else + str = str.replace(rules[i].rex, rules[i].tmplt); + } + return str; + }, + store: function(str, unresolved) { + return unresolved ? "@" + (Wiky.blocks.push(str)-1) + "@" + : "@" + (Wiky.blocks.push(str.replace(/@([0-9]+)@/g, function($0,$1){return Wiky.restore($1);}))-1) + "@"; + }, + restore: function(idx) { + return Wiky.blocks[idx]; + }, + attr: function(str, name, idx) { + var a = str && str.split(",")[idx||0]; + return a ? (name ? (" "+name+"=\""+a+"\"") : a) : ""; + }, + hasAttr: function(str, name) { + return new RegExp(name+"=").test(str); + }, + attrVal: function(str, name) { + return str.replace(new RegExp("^.*?"+name+"=\"(.*?)\".*?$"), "$1"); + }, + invAttr: function(str, names) { + var a=[], x; + for (var i in names) + if (str.indexOf(names[i]+"=")>=0) + a.push(str.replace(new RegExp("^.*?"+names[i]+"=\"(.*?)\".*?$"), "$1")); + return a.length ? ("("+a.join(",")+")") : ""; + }, + style: function(str) { + var s = str && str.split(/,|;/), p, style = ""; + for (var i in s) { + p = s[i].split(":"); + if (p[0] == ">") style += "margin-left:4em;"; + else if (p[0] == "<") style += "margin-right:4em;"; + else if (p[0] == ">>") style += "float:right;"; + else if (p[0] == "<<") style += "float:left;"; + else if (p[0] == "=") style += "display:block;margin:0 auto;"; + else if (p[0] == "_") style += "text-decoration:underline;"; + else if (p[0] == "b") style += "border:solid 1px;"; + else if (p[0] == "c") style += "color:"+p[1]+";"; + else if (p[0] == "C") style += "background:"+p[1]+";"; + else if (p[0] == "w") style += "width:"+p[1]+";"; + else style += p[0]+":"+p[1]+";"; + } + return style ? " style=\""+style+"\"" : ""; + }, + invStyle: function(str) { + var s = /style=/.test(str) ? str.replace(/^.*?style=\"(.*?)\".*?$/, "$1") : "", + p = s && s.split(";"), pi, prop = []; + for (var i in p) { + pi = p[i].split(":"); + if (pi[0] == "margin-left" && pi[1]=="4em") prop.push(">"); + else if (pi[0] == "margin-right" && pi[1]=="4em") prop.push("<"); + else if (pi[0] == "float" && pi[1]=="right") prop.push(">>"); + else if (pi[0] == "float" && pi[1]=="left") prop.push("<<"); + else if (pi[0] == "margin" && pi[1]=="0 auto") prop.push("="); + else if (pi[0] == "display" && pi[1]=="block") ; + else if (pi[0] == "text-decoration" && pi[1]=="underline") prop.push("_"); + else if (pi[0] == "border" && pi[1]=="solid 1px") prop.push("b"); + else if (pi[0] == "color") prop.push("c:"+pi[1]); + else if (pi[0] == "background") prop.push("C:"+pi[1]); + else if (pi[0] == "width") prop.push("w:"+pi[1]); + else if (pi[0]) prop.push(pi[0]+":"+pi[1]); + } + return prop.length ? ("{" + prop.join(",") + "}") : ""; + }, + sectionRule: function(fromLevel, style, content, toLevel) { + var trf = { p_p: "
$1
", + p_u: "$1
", + p_o: "
", + u_c: "$1
", + // p - ul + // ul - p + u_p: "
- $1
$1 ", + u_r: "$1 ", + uu_p: "$1 ", + uo_p: "$1 ", + uuu_p: "$1 ", + uou_p: "$1 ", + uuo_p: "$1 ", + uoo_p: "$1 ", + // ul - ul + u_u: "$1 ", + uu_u: "$1 ", + uo_u: "$1 ", + uuu_u: "$1 ", + uou_u: "$1 ", + uuo_u: "$1 ", + uoo_u: "$1 ", + u_uu: "$1 ", + // ul - ol + u_o: "
- $1
", + uu_o: "
- $1
", + uo_o: "
- $1
", + uuu_o: "
- $1
", + uou_o: "
- $1
", + uuo_o: "
- $1
", + uoo_o: "
- $1
", + u_uo: "
", + ou_p: "- $1
", + // ol - p + o_p: "
", + oo_p: "- $1
- $1
$1 ", + ooo_p: "$1 ", + ouo_p: "$1 ", + oou_p: "$1 ", + ouu_p: "$1 ", + // ol - ul + o_u: "$1 ", + oo_u: "
", + oou_o: "- $1
", + ou_u: "
- $1
", + ooo_u: "
- $1
", + ouo_u: "
- $1
", + oou_u: "
- $1
", + ouu_u: "
- $1
", + o_ou: "
", + ooo_o: "- $1
", + ou_o: "", + // -- ol - ol -- + o_o: "
- $1
", + oo_o: "- $1
- $1
- $1
", + ouo_o: "- $1
$1 ", + ouu_o: "$1 ", + o_oo: "$1 ", + // -- dl -- + l_d: "
- $1
", + d_l: "- $1
", + d_u: "- $1
", + d_o: "
- $1
", + p_l: "
$1
", + u_l: "
- $1
", + o_l: "
- $1
", + uu_l: "
$1 ", + uo_l: "
$1 ", + ou_l: "
$1 ", + oo_l: "
$1 ", + d_p: "
", + // -- table -- + p_t: "- $1
$1
", + p_r: "
$1
", + p_c: "$1
", + t_p: "$1
", + r_r: "", + r_p: " $1 $1
", + r_c: "$1 ", + r_u: "", + c_c: " $1 ", + c_p: "
$1
", + c_r: "$1 $1 ", +// c_u: "$1 ", + u_t: "
- $1
", + o_t: "
$1 ", + d_t: "
$1 ", + t_u: "
$1
", + t_o: "
$1
", + t_l: "
$1
" + }; + var type = { "0": "decimal-leading-zero", + "1": "decimal", + "a": "lower-alpha", + "A": "upper-alpha", + "i": "lower-roman", + "I": "upper-roman", + "g": "lower-greek" }; + + var from = "", to = "", maxlen = Math.max(fromLevel.length, toLevel.length), sync = true, sectiontype = type[toLevel.charAt(toLevel.length-1)], transition; + + for (var i=0; i
<\/p>/, ""); + } +} diff --git a/modules/wiky.lang.css b/modules/wiky.lang.css new file mode 100755 index 0000000..0d61d75 --- /dev/null +++ b/modules/wiky.lang.css @@ -0,0 +1,9 @@ +pre.syntax { font-size:100%; background: #eed; border:1px dotted #999; padding:0 0.5em; overflow:auto; } +span.cmt { font-style: italic; color: green; } +span.str { font-style: italic; color: darkred; } +span.kwd { color: blue; } +span.obj { color: purple; } +span.mbr { color: gray; } +span.xtag { color: blue; } +span.xnam { color: purple; } +span.xval { font-style: italic; color: darkred; } diff --git a/modules/wiky.lang.js b/modules/wiky.lang.js new file mode 100755 index 0000000..dd53e83 --- /dev/null +++ b/modules/wiky.lang.js @@ -0,0 +1,40 @@ +/* This work is licensed under Creative Commons GNU LGPL License. + + License: http://creativecommons.org/licenses/LGPL/2.1/ + + Author: Stefan Goessner/2005-06 + Web: http://goessner.net/ + + credits: http://www.regular-expressions.info/examplesprogrammer.html +*/ +Wiky.rules.lang.js = [ + "Wiky.rules.code", + { rex:/"([^"\\\xB6]*(\\.[^"\\\xB6]*)*)"/g, tmplt:function($0,$1){return Wiky.store("\""+$1+"\"");}}, // string delimited by '"' with '\"' allowed .. + { rex:/'([^'\\\xB6]*(\\.[^'\\\xB6]*)*)'/g, tmplt:function($0,$1){return Wiky.store("\'"+$1+"\'");}}, // string delimited by "'" with "\'" allowed .. + { rex:/\/\/(.*?)(?:\xB6|$)/g, tmplt:function($0,$1){return Wiky.store("//"+$1+"\xB6");}}, // single line comment + { rex:/\/\*(.*?)\*\//g, tmplt:function($0,$1){return Wiky.store("\/*"+$1+"*\/");}}, // multi-line comment +// { rex:/([\]\[\-+\|*!%<>=\{\}?:,\)\(]+)|("|/|=)+/g, tmplt:"$1"}, // operators + { rex:/\b(break|case|catch|continue|do|else|false|for|function|if|in|new|return|switch|this|throw|true|try|var|while|with)\b/g, tmplt:"$1" }, // keywords + { rex:/\b(arguments|Array|Boolean|Date|Error|Function|Global|Math|Number|Object|RegExp|String)\b/g, tmplt:"$1" }, // objects + { rex:/\.(abs|acos|anchor|arguments|asin|atan|atan2|big|blink|bold|callee|caller|ceil|charAt|charCodeAt|concat|constructor|cos|E|escape|eval|exp|fixed|floor|fontcolor|fontsize|fromCharCode|getDate|getDay|getFullYear|getHours|getMilliseconds|getMinutes|getMonth|getSeconds|getTime|getTimezoneOffset|getUTCDate|getUTCDay|getUTCFullYear|getUTCHours|getUTCMilliseconds|getUTCMinutes|getUTCMonth|getUTCSeconds|getVarDate|getYear|index|indexOf|Infinity|input|isFinite|isNaN|italics|join|lastIndex|lastIndexOf|lastMatch|lastParen|leftContext|length|link|LN10|LN2|log|LOG10E|LOG2E|match|max|MAX_VALUE|min|MIN_VALUE|NaN|NaN|NEGATIVE_INFINITY|parse|parseFloat|parseInt|PI|pop|POSITIVE_INFINITY|pow|prototype|push|random|replace|reverse|rightContext|round|search|setDate|setFullYear|setHours|setMilliseconds|setMinutes|setMonth|setSeconds|setTime|setUTCDate|setUTCFullYear|setUTCHours|setUTCMilliseconds|setUTCMinutes|setUTCMonth|setUTCSeconds|setYear|shift|sin|slice|slice|small|sort|splice|split|sqrt|SQRT1_2|SQRT2|strike|sub|substr|substring|sup|tan|toGMTString|toLocaleString|toLowerCase|toString|toUpperCase|toUTCString|unescape|unshift|UTC|valueOf)\b/g, tmplt:".$1" }, // members +]; +Wiky.rules.lang.xml = [ + { rex:/";} }, // script blocks .. + { rex://g, tmplt:function($0,$1){return Wiky.store("<![CDATA["+$1+"]]>");} }, // CDATA sections, .. + { rex://g, tmplt:function($0,$1){return Wiky.store("<!"+$1+">");} }, // inline xml comments, doctypes, .. + { rex://g, tmplt:"\xBB"}, // replace '>' by '»' + { rex:/([-A-Za-z0-9_:]+)[ ]*=[ ]*\"(.*?)\"/g, tmplt:"$1="$2""}, // "xml attribute value strings .. + { rex:/(\xAB[\/]?)([-A-Za-z0-9_:]+)/g, tmplt:"$1$2"}, // "xml tag .. + { rex:/\xAB/g, tmplt:"<"}, // replace '«' by '<' + { rex:/\xBB/g, tmplt:">"}, // replace '»' by '>' +]; +Wiky.inverse.lang.js = [ + { rex:/|<\/span>/mgi, tmplt:"" }, + { rex:/(.*?)<\/strong>/mgi, tmplt:"[*$1*]" }, + "Wiky.inverse.code" +]; +Wiky.inverse.lang.xml = [ + { rex:/|<\/span>/mgi, tmplt:"" }, + "Wiky.inverse.lang.js" +]; diff --git a/modules/wiky.math.css b/modules/wiky.math.css new file mode 100755 index 0000000..de2a6f5 --- /dev/null +++ b/modules/wiky.math.css @@ -0,0 +1,88 @@ +/* math */ +dfn, div.eq { + white-space: nowrap; + font-family: sans-serif; + font-style: normal; + color: navy; +} +div.eq { + margin-left: 3em; + margin-right: 1em; +} +div.eq a {float:right} + +span.h { /* huge */ + font-size:150%; +} + +span.o, span.s, span.f { + display:-moz-inline-box; + -moz-box-orient:vertical; + display:inline-block; + vertical-align:middle; + margin:0 0.2em; +} + +span.x, span.i, span.d, span.n, span.o span { + display: block; +} + +span.x, span.d, span.n, span.s, span.o span { + text-align:center; + margin:0 0.2em; +} + +span.n, span.d { + font-size: 90%; +} + +span.i { + text-align: left; + margin:0 0.2em 0 0; +} +span.b { + font-weight: bold; +} + +span.x, span.i, span.f span.f { + font-size: 80%; +} + +span.n { + border-bottom:solid 1px navy; +} + +span.v, span.m { + display:-moz-inline-box; + -moz-box-orient:vertical; + display:inline-block; + vertical-align:middle; +} +span.v span.e, span.m span.e { + font-size: 90%; + white-space:nowrap; + display: block; + text-align:center; + margin:0.2em; +} +/*span.m > span.e { height:2em; }*/ /* hide ie 6 */ + +span.lb, span.rb { + margin:0; + padding:0; + vertical-align: middle; + border-top:1px solid navy; + border-bottom:1px solid navy; +} +span.lb { + border-left:1px solid navy; +} +span.rb { + border-right:1px solid navy; +} +span.lbrk2, span.rbrk2 { + font-size:200%; +} +span.lbrk3, span.rbrk3 { + font-size:300%; +} diff --git a/modules/wiky.math.js b/modules/wiky.math.js new file mode 100755 index 0000000..26cf41e --- /dev/null +++ b/modules/wiky.math.js @@ -0,0 +1,374 @@ +/* This work is licensed under Creative Commons GNU LGPL License. + + License: http://creativecommons.org/licenses/LGPL/2.1/ + + Author: Stefan Goessner/2005-06 + Web: http://goessner.net/ + inspired by: http://xml-maiden.com/ +*/ +Wiky.rules.math = { + version: 0.95, + preshortcuts: [ +// { rex:/[ ]/g, tmplt:"`"}, // omit due to charset support ie6 + { rex:/\+\-/g, tmplt:"±"}, + { rex:/\/O|\\Oslash/g, tmplt:"Ø"}, + { rex:/\/o|\\oslash/g, tmplt:"ø"}, + { rex:/<->|\\harr/g, tmplt:"↔"}, + { rex:/<-|\\larr/g, tmplt:"←"}, + { rex:/->|\\rarr/g, tmplt:"→"}, + { rex:/<=>|\\hArr/g, tmplt:"⇔"}, + { rex:/=>|\\rArr/g, tmplt:"⇒"}, + { rex:/-=|\\equiv/g, tmplt:"≡"}, + { rex:/<=|\\le/g, tmplt:"≤"}, + { rex:/>=|\\ge/g, tmplt:"≥"}, + { rex://g, tmplt:">"} + ], + postshortcuts: [ + { rex:/\*|\\middot/g, tmplt:"·"}, + { rex:/\\x|\\times/g, tmplt:"×"}, + { rex:/~=|\\cong/g, tmplt:"≅"}, + { rex:/~~|\\asymp/g, tmplt:"≈"}, + { rex:/~|\\sim/g, tmplt:"∼"}, + { rex:/!=|\\neq|\\ne/g, tmplt:"≠"}, + { rex:/\.\.\.|\\ldots/g, tmplt:"…"}, + { rex:/\\in|\\isin/g, tmplt:"∈"}, + { rex:/([0-9])x([0-9])/g, tmplt:"$1×$2"}, + { rex:/([A-Za-z]) x ([A-Za-z])/g, tmplt:"$1×$2"}, +// { rex:/[`]{4}/g, tmplt:" "}, // omit due to charset support ie6 +// { rex:/[`]{3}/g, tmplt:" "}, +// { rex:/[`]{2}/g, tmplt:" "}, +// { rex:/[`]/g, tmplt:" "}, + { rex:/\{/g, tmplt:""}, // unvisible left-to-right mark, + { rex:/\}/g, tmplt:""} // unvisible right-to-left mark, + ], + expr: [ + { rex:/\^\^/g, tmplt:"^^"}, // ^ overindex + { rex:/(\\sum|\\prod|\\int)_([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})\^([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:"$3$1$2"}, // over-/underscript (\sum, \prod, \int) + { rex:/(\\sum|\\prod|\\int)\^([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:"$2$1 "}, + { rex:/(\\sum|\\prod|\\int)_([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:" $1$2"}, + { rex:/_([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})\^([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:"$2$1"}, // over-/underindex + { rex:/\^([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:"$1"}, // overindex + { rex:/_([-]?[a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:"$1"}, // underindex + { rex:/-/g, tmplt:"−"}, + { rex:/([a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})\/([a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:"$1$2"}, // fraction + { rex:/([a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})\/\/([a-zA-Z0-9\.&;#\\]+|\{@[0-9]+@\})/g, tmplt:"$1⁄$2"}, // fraction + { rex:/\[((\[(([^,\]]+[,]){1,}[^\]]+)\][ \n]*){1,})\]/g, tmplt:function($0,$1){var m=Wiky.math.transpose($1.replace(/(^\[|\]$)/g,"").replace(/(\][ \n]*\[)/g,"|").split("|")),sz=" style=\"font-size:"+(m.len)+"00%;\"";/*alert("{("+m.mat.join(")}\n{(").split(",").join(")(")+")}");*/ return ""+Wiky.math.fence()+""+m.mat.join("\n").split(",").join("")+""+Wiky.math.fence()+"";}}, // matrix + { rex:/\[((?:[^,\]]){1,}[^\]]+)\]/g, tmplt:function($0,$1){var v=$1.split(","),sz=" style=\"font-size:"+v.length+"00%;\""; return ""+Wiky.math.fence()+""+v.join("")+""+Wiky.math.fence()+"";}}, // vector + { rex:/!([a-zA-Z0-9\.&;]+)/g, tmplt:"$1" }, // bold vector symbol .. + { rex:/\\prod/g, tmplt:"∏"}, + { rex:/\\sum/g, tmplt:"∑"}, + { rex:/\\int/g, tmplt:"∫"}, + "Wiky.rules.math.postshortcuts" + ], + symbols: [ + { rex:/\\Alpha/g, tmplt:"Α"}, + { rex:/\\Beta/g, tmplt:"Β"}, + { rex:/\\Gamma/g, tmplt:"Γ"}, + { rex:/\\Delta/g, tmplt:"Δ"}, + { rex:/\\Epsilon/g, tmplt:"Ε"}, + { rex:/\\Zeta/g, tmplt:"Ζ"}, + { rex:/\\Eta/g, tmplt:"Η"}, + { rex:/\\Theta/g, tmplt:"Θ"}, + { rex:/\\Iota/g, tmplt:"Ι"}, + { rex:/\\Kappa/g, tmplt:"Κ"}, + { rex:/\\Lambda/g, tmplt:"Λ"}, + { rex:/\\Mu/g, tmplt:"Μ"}, + { rex:/\\Nu/g, tmplt:"Ν"}, + { rex:/\\Xi/g, tmplt:"Ξ"}, + { rex:/\\Omicron/g, tmplt:"Ο"}, + { rex:/\\Pi/g, tmplt:"Π"}, + { rex:/\\Rho/g, tmplt:"Ρ"}, + { rex:/\\Sigma/g, tmplt:"Σ"}, + { rex:/\\Tau/g, tmplt:"Τ"}, + { rex:/\\Upsilon/g, tmplt:"Υ"}, + { rex:/\\Phi/g, tmplt:"Φ"}, + { rex:/\\Chi/g, tmplt:"Χ"}, + { rex:/\\Psi/g, tmplt:"Ψ"}, + { rex:/\\Omega/g, tmplt:"Ω"}, + { rex:/\\alpha/g, tmplt:"α"}, + { rex:/\\beta/g, tmplt:"β"}, + { rex:/\\gamma/g, tmplt:"γ"}, + { rex:/\\delta/g, tmplt:"δ"}, + { rex:/\\epsilon/g, tmplt:"ε"}, + { rex:/\\zeta/g, tmplt:"ζ"}, + { rex:/\\eta/g, tmplt:"η"}, + { rex:/\\thetasym/g, tmplt:"ϑ"}, + { rex:/\\theta/g, tmplt:"θ"}, + { rex:/\\iota/g, tmplt:"ι"}, + { rex:/\\kappa/g, tmplt:"κ"}, + { rex:/\\lambda/g, tmplt:"λ"}, + { rex:/\\mu/g, tmplt:"μ"}, + { rex:/\\nu/g, tmplt:"ν"}, + { rex:/\\xi/g, tmplt:"ξ"}, + { rex:/\\omicron/g, tmplt:"ο"}, + { rex:/\\piv/g, tmplt:"ϖ"}, + { rex:/\\pi/g, tmplt:"π"}, + { rex:/\\rho/g, tmplt:"ρ"}, + { rex:/\\sigmaf/g, tmplt:"ς"}, + { rex:/\\sigma/g, tmplt:"σ"}, + { rex:/\\tau/g, tmplt:"τ"}, + { rex:/\\upsilon/g, tmplt:"υ"}, + { rex:/\\phi/g, tmplt:"φ"}, + { rex:/\\chi/g, tmplt:"χ"}, + { rex:/\\psi/g, tmplt:"ψ"}, + { rex:/\\omega/g, tmplt:"ω"}, + { rex:/\\upsih/g, tmplt:"ϒ"}, + // miscellaneous symbols + { rex:/\\bull/g, tmplt:"•"}, + { rex:/\\uarr/g, tmplt:"↑"}, + { rex:/\\darr/g, tmplt:"↓"}, + { rex:/\\crarr/g, tmplt:"↵"}, + { rex:/\\lArr/g, tmplt:"⇐"}, + { rex:/\\uArr/g, tmplt:"⇑"}, + { rex:/\\dArr/g, tmplt:"⇓"}, + { rex:/\\forall/g, tmplt:"∀"}, + { rex:/\\part/g, tmplt:"∂"}, + { rex:/\\exist/g, tmplt:"∃"}, + { rex:/\\empty/g, tmplt:"∅"}, + { rex:/\\nabla/g, tmplt:"∇"}, + { rex:/\\notin/g, tmplt:"∉"}, + { rex:/\\ni/g, tmplt:"∋"}, + { rex:/\\minus/g, tmplt:"−"}, + { rex:/\\lowast/g, tmplt:"∗"}, + { rex:/\\sqrt|\\radic/g, tmplt:"√"}, + { rex:/\\prop/g, tmplt:"∝"}, + { rex:/\\infin/g, tmplt:"∞"}, + { rex:/\\ang/g, tmplt:"∠"}, + { rex:/\\and/g, tmplt:"∧"}, + { rex:/\\or/g, tmplt:"∨"}, + { rex:/\\cap/g, tmplt:"∩"}, + { rex:/\\cup/g, tmplt:"∪"}, + { rex:/\\there4/g, tmplt:"∴"}, + { rex:/\\sub/g, tmplt:"⊂"}, + { rex:/\\sup/g, tmplt:"⊃"}, + { rex:/\\nsub/g, tmplt:"⊄"}, + { rex:/\\sube/g, tmplt:"⊆"}, + { rex:/\\supe/g, tmplt:"⊇"}, + { rex:/\\oplus/g, tmplt:"⊕"}, + { rex:/\\otimes/g, tmplt:"⊗"}, + { rex:/\\perp/g, tmplt:"⊥"}, + { rex:/\\sdot/g, tmplt:"⋅"} + ] +}; + +Wiky.inverse.math = { + pre: [ + { rex:/−|\u2212/g, tmplt:"-"}, + { rex:/ |\u2009/g, tmplt:" "}, + { rex:/|\u200E/g, tmplt:"{"}, + { rex:/|\u200F/g, tmplt:"}"} + ], + post: [ +// { rex:/([$])/g, tmplt:"\\$1" }, + { rex:/^|\x5E/g, tmplt:"^"}, + { rex:/</g, tmplt:"<"}, + { rex:/>/g, tmplt:">"} + ], + shortcuts: [ +// { rex:/ |\u2003/g, tmplt:" "}, // omit due to charset support ie6 +// { rex:/ |\u2002/g, tmplt:" "}, +// { rex:/ |\u2009/g, tmplt:" "}, + { rex:/±|\xB1/g, tmplt:"+-"}, + { rex:/·|\xB7/g, tmplt:"*"}, + { rex:/×|\xD7/g, tmplt:"\\x"}, + { rex:/Ø|\xD8/g, tmplt:"/O"}, + { rex:/ø|\xF8/g, tmplt:"/o"}, + { rex:/←|\u2190/g, tmplt:"<-"}, + { rex:/→|\u2192/g, tmplt:"->"}, + { rex:/↔|\u2194/g, tmplt:"<->"}, + { rex:/⇒|\u21D2/g, tmplt:"=>"}, + { rex:/⇔|\u21D4/g, tmplt:"<=>"}, + { rex:/∼|\u223C/g, tmplt:"~"}, + { rex:/≅|\u2245/g, tmplt:"~="}, + { rex:/≈|\u2248/g, tmplt:"~~"}, + { rex:/≠|\u2260/g, tmplt:"!="}, + { rex:/…/g, tmplt:"..."}, + { rex:/≡|\u2261/g, tmplt:"-="}, + { rex:/≤|\u2264/g, tmplt:"<="}, + { rex:/≥|\u2265/g, tmplt:">="} + ], + expr: [ + { rex:/(\{?@[0-9]+@\}?)<\/span>(\{?@[0-9]+@\}?)<\/span><\/span>/g, tmplt:"_$2^$1"}, // superscript + subscript + { rex:/(\{?@[0-9]+@\}?)<\/span>(\\prod|\\sum|\\int)(\{?@[0-9]+@\}?)<\/span><\/span>/g, tmplt:"$2_$3^$1"}, // overscript + underscript + { rex:/@[0-9]+@<\/span>(\\prod|\\sum|\\int)(\{?@[0-9]+@\}?)<\/span><\/span>/mgi, tmplt:"$1_$2", dbg:true}, // underscript + { rex:/(\{?@[0-9]+@\}?)<\/span>(\\prod|\\sum|\\int)@[0-9]+@<\/span><\/span>/mgi, tmplt:"$2^$1"}, // overscript + { rex:/(\{?@[0-9]+@\}?)<\/span>(\{?@[0-9]+@\}?)<\/span><\/span>/mgi, tmplt:"$1/$2"}, // fraction + { rex:/]*>&[^;]+;<\/span>((?:[^>]*<\/span>){2,})<\/span>]*>&[^;]+;<\/span>/mgi, tmplt:function($0,$1){return "["+$1.replace(/(?:^|<\/span>$)/g,"").replace(/<\/span>/g,",")+"]";}}, // vector .. + { rex:/]*>&[^;]+;<\/span>((?:(?:(?:[^>]*<\/span>){2,})<\/span>[^>]*){2,})]*>&[^;]+;<\/span>/mgi, tmplt:function($0,$1){return "[["+Wiky.math.transpose($1.replace(/(?:^|<\/span><\/span>$)/g,"").replace(/<\/span>/g,",").replace(/<\/span><\/span>[^>]*/g,"|").split("|")).mat.join("][")+"]]";}}, // matrix .. + { rex:/(@[0-9]+@)<\/span>/mgi, tmplt:"!$1"}, // bold vector .. + { rex:/(\{?@[0-9]+@\}?)<\/sup>⁄(\{?@[0-9]+@\}?)<\/sub>/mgi, tmplt:"$1//$2"}, + { rex:/(\{?@[0-9]+@\}?)<\/sup>/mgi, tmplt:"^$1" }, + { rex:/(\{?@[0-9]+@\}?)<\/sub>/mgi, tmplt:"_$1" } + ], + symbols: [ + // greek symbols + { rex:/Α|\u391/g, tmplt:"\\Alpha"}, + { rex:/Β|\u392/g, tmplt:"\\Beta"}, + { rex:/Γ|\u393/g, tmplt:"\\Gamma"}, + { rex:/Δ|\u394/g, tmplt:"\\Delta"}, + { rex:/Ε|\u395/g, tmplt:"\\Epsilon"}, + { rex:/Ζ|\u396/g, tmplt:"\\Zeta"}, + { rex:/Η|\u397/g, tmplt:"\\Eta"}, + { rex:/Θ|\u398/g, tmplt:"\\Theta"}, + { rex:/Ι|\u399/g, tmplt:"\\Iota"}, + { rex:/Κ|\u39A/g, tmplt:"\\Kappa"}, + { rex:/Λ|\u39B/g, tmplt:"\\Lambda"}, + { rex:/Μ|\u39C/g, tmplt:"\\Mu"}, + { rex:/Ν|\u39D/g, tmplt:"\\Nu"}, + { rex:/Ξ|\u39E/g, tmplt:"\\Xi"}, + { rex:/Ο|\u39F/g, tmplt:"\\Omicron"}, + { rex:/Π|\u3A0/g, tmplt:"\\Pi"}, + { rex:/Ρ|\u3A1/g, tmplt:"\\Rho"}, + { rex:/Σ|\u3A3/g, tmplt:"\\Sigma"}, + { rex:/Τ|\u3A4/g, tmplt:"\\Tau"}, + { rex:/Υ|\u3A5/g, tmplt:"\\Upsilon"}, + { rex:/Φ|\u3A6/g, tmplt:"\\Phi"}, + { rex:/Χ|\u3A7/g, tmplt:"\\Chi"}, + { rex:/Ψ|\u3A8/g, tmplt:"\\Psi"}, + { rex:/Ω|\u3A9/g, tmplt:"\\Omega"}, + { rex:/α|\u3B1/g, tmplt:"\\alpha"}, + { rex:/β|\u3B2/g, tmplt:"\\beta"}, + { rex:/γ|\u3B3/g, tmplt:"\\gamma"}, + { rex:/δ|\u3B4/g, tmplt:"\\delta"}, + { rex:/ε|\u3B5/g, tmplt:"\\epsilon"}, + { rex:/ζ|\u3B6/g, tmplt:"\\zeta"}, + { rex:/η|\u3B7/g, tmplt:"\\eta"}, + { rex:/ϑ|\u3D1/g, tmplt:"\\thetasym"}, + { rex:/θ|\u3B8/g, tmplt:"\\theta"}, + { rex:/ι|\u3B9/g, tmplt:"\\iota"}, + { rex:/κ|\u3BA/g, tmplt:"\\kappa"}, + { rex:/λ|\u3BB/g, tmplt:"\\lambda"}, + { rex:/μ|\u3BC/g, tmplt:"\\mu"}, + { rex:/ν|\u3BD/g, tmplt:"\\nu"}, + { rex:/ξ|\u3BE/g, tmplt:"\\xi"}, + { rex:/ο|\u3BF/g, tmplt:"\\omicron"}, + { rex:/π|\u3C0/g, tmplt:"\\pi"}, + { rex:/ρ|\u3C1/g, tmplt:"\\rho"}, + { rex:/ς|\u3C2/g, tmplt:"\\sigmaf"}, + { rex:/σ|\u3C3/g, tmplt:"\\sigma"}, + { rex:/τ|\u3C4/g, tmplt:"\\tau"}, + { rex:/υ|\u3C5/g, tmplt:"\\upsilon"}, + { rex:/φ|\u3C6/g, tmplt:"\\phi"}, + { rex:/χ|\u3C7/g, tmplt:"\\chi"}, + { rex:/ψ|\u3C8/g, tmplt:"\\psi"}, + { rex:/ω|\u3C9/g, tmplt:"\\omega"}, + // miscellaneous symbols + { rex:/ϒ|\u3D2/g, tmplt:"\\upsih"}, + { rex:/ϖ|\u3D6/g, tmplt:"\\piv"}, + { rex:/•|\u2022/g, tmplt:"\\bull"}, + { rex:/↑|\u2191/g, tmplt:"\\uarr"}, + { rex:/↓|\u2193/g, tmplt:"\\darr"}, + { rex:/↵|\u21B5/g, tmplt:"\\crarr"}, + { rex:/⇐|\u21D0/g, tmplt:"\\lArr"}, + { rex:/⇑|\u21D1/g, tmplt:"\\uArr"}, + { rex:/⇓|\u21D3/g, tmplt:"\\dArr"}, + { rex:/∀|\u2200/g, tmplt:"\\forall"}, + { rex:/∂|\u2202/g, tmplt:"\\part"}, + { rex:/∃|\u2203/g, tmplt:"\\exist"}, + { rex:/∅|\u2205/g, tmplt:"\\empty"}, + { rex:/∇|\u2207/g, tmplt:"\\nabla"}, + { rex:/∈|\u2208/g, tmplt:"\\isin"}, + { rex:/∉|\u2209/g, tmplt:"\\notin"}, + { rex:/∋|\u220B/g, tmplt:"\\ni"}, + { rex:/(∏|\u220F)<\/span>/g, tmplt:"\\prod"}, + { rex:/(∑|\u2211)<\/span>/g, tmplt:"\\sum"}, + { rex:/∗|\u2217/g, tmplt:"\\lowast"}, + { rex:/√|\u221A/g, tmplt:"\\sqrt"}, + { rex:/∝|\u221D/g, tmplt:"\\prop"}, + { rex:/∞|\u221E/g, tmplt:"\\infin"}, + { rex:/∠|\u2220/g, tmplt:"\\ang"}, + { rex:/∧|\u2227/g, tmplt:"\\and"}, + { rex:/∨|\u2228/g, tmplt:"\\or"}, + { rex:/∩|\u2229/g, tmplt:"\\cap"}, + { rex:/∪|\u222A/g, tmplt:"\\cup"}, + { rex:/(?:∫|\u222B)<\/span>/g, tmplt:"\\int"}, + { rex:/∴|\u2234/g, tmplt:"\\there4"}, + { rex:/⊂|\u2282/g, tmplt:"\\sub"}, + { rex:/⊃|\u2283/g, tmplt:"\\sup"}, + { rex:/⊄|\u2284/g, tmplt:"\\nsub"}, + { rex:/⊆|\u2286/g, tmplt:"\\sube"}, + { rex:/⊇|\u2287/g, tmplt:"\\supe"}, + { rex:/⊕|\u2295/g, tmplt:"\\oplus"}, + { rex:/⊗|\u2297/g, tmplt:"\\otimes"}, + { rex:/⊥|\u22A5/g, tmplt:"\\perp"}, + { rex:/⋅|\u22C5/g, tmplt:"\\sdot"} + ] +}; + +Wiky.math = { + toHtml: function(str) { + var expr = function(itr) { // region from "{" to "}", nesting allowed .. + var s = ""; + for (var c = itr.str.charAt(itr.pos++); itr.pos <= itr.str.length && c != "}"; c = itr.str.charAt(itr.pos++)) + s += (c == "{") ? ("{"+expr(itr)+"}") : c; + return Wiky.store(Wiky.apply(s, Wiky.rules.math.expr)); + }; + str = Wiky.apply(str, Wiky.rules.math.preshortcuts); + str = Wiky.apply(str, Wiky.rules.math.symbols); + str = expr({str:str,pos:0}); + return str; + }, + toWiki: function(str) { + var parseTree = function(itr, endtag) { + var c, s="",gt,nam,idxof=function(s,c,p){var i=s.indexOf(c,p);return i>=0?i:s.length;} + for (itr.buf=itr.str.substr(itr.pos,endtag.length); + itr.pos ",itr.pos)) < idxof(itr.str,"/",itr.pos)) { // start tags .. no empty elements or endtags .. + nam = itr.str.substring(itr.pos+1,Math.min(idxof(itr.str," ",itr.pos),gt)); + s += itr.str.substring(itr.pos,itr.pos=gt+1) + parseTree(itr, "" + nam + ">") + "" + nam + ">"; + itr.pos += nam.length+3; + } + else + s += c; + } + itr.pos--; + return Wiky.store(s, true); + }; + str = Wiky.apply(str, Wiky.inverse.math.pre); + str = Wiky.apply(str, Wiky.inverse.math.symbols); + str = parseTree({str:str,pos:0,buf:null}, ""); + while (str.match(/@[0-9]+@/g) != null) + str = Wiky.apply(str.replace(/@([0-9]+)@/g, function($0,$1){return Wiky.restore($1);}), Wiky.inverse.math.expr); + str = Wiky.apply(str, Wiky.inverse.math.shortcuts); + str = Wiky.apply(str, Wiky.inverse.math.post); + return str; + }, + fence: function(str) { + return window && window.ActiveXObject ? " " : " "; + }, + transpose: function (m) { + var t=[]; + for (var i in m) { + m[i] = m[i].split(","); + for (var j in m[i]) { + if (!t[j]) t[j]=[]; + t[j][i] = m[i][j]; + } + } + for (var i in t) + t[i] = t[i].join(","); + return {mat:t, len:m.length}; + } +}; + +Wiky.rules.pre = Wiky.rules.pre.concat({ rex:/\\([$])/g, tmplt:function($0,$1){return Wiky.store($1);} }); +Wiky.rules.nonwikiblocks = Wiky.rules.nonwikiblocks.concat( +[ + { rex:/\[\(([a-zA-Z0-9\.-]+)\)\$([^$]*)\$\]/g, tmplt:function($0,$1,$2){return ":p] ("+$1+")" + Wiky.math.toHtml($2) + "[p:";} }, // numbered equation + { rex:/\[\$([^$]*)\$\]/g, tmplt:function($0,$1){return ":p]" + Wiky.math.toHtml($1) + "[p:";} }, // equation +]); +Wiky.rules.nonwikiinlines = Wiky.rules.nonwikiinlines.concat( + { rex:/\$([^$]*)\$/g, tmplt:function($0,$1){return "" + Wiky.math.toHtml($1) + "";} } // inline equation +); + +Wiky.inverse.pre = Wiky.inverse.pre.concat({ rex:/([\$])/g, tmplt:"\\$1" }); +Wiky.inverse.nonwikiblocks = Wiky.inverse.nonwikiblocks.concat( +[ + { rex:/