]*?>(.*?)<\/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);
- },
+ 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" + $2 + "\xB6[p:";
+ }
+ }, // ..
+ {
+ rex: /(?:^|\xB6)[-]{4}(?:\xB6|$)/g,
+ tmplt: "\xB6
\xB6"
+ }, // horizontal ruler ..
+ {
+ rex: /\\\\([ \xB6])/g,
+ tmplt: "
$1"
+ }, // forced line break ..
+ {
+ rex: /(^|\xB6)([*01aAiIg]*[\.*])[ ]/g,
+ tmplt: function($0, $1, $2) {
+ var state = $2.replace(/([*])/g, "u").replace(/([\.])/, "");
+ return ":" + state + "]" + $1 + "[" + state + ":";
+ }
+ }, {
+ rex: /(?:^|\xB6);[ ](.*?):[ ]/g,
+ tmplt: "\xB6:l][l:$1:d][d:"
+ }, // ; term : definition
+ {
+ rex: /\[(?:\{([^}]*)\})?(?:\(([^)]*)\))?\"/g,
+ tmplt: function($0, $1, $2) {
+ return ":p][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: /(?:([0-9]*)[>])?([ ]?)(.*?)([ ]?)<\/td>/g,
+ tmplt: function($0, $1, $2, $3, $4) {
+ return " | " + $2 + $3 + $4 + " | ";
+ }
+ }, {
+ rex: /<(p|table)>(?:\xB6)?(?:\{(.*?)\})/g,
+ tmplt: function($0, $1, $2) {
+ return "<" + $1 + Wiky.style($2) + ">";
+ }
+ }, {
+ 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: /