Difference between revisions 137478 and 137502 on testwiki

/// PerfektesChaos/js/WikisyntaxTextMod/?W.js
/// 2012-06-145 [email protected]
/// Fingerprint: #0#0#
/// <nowiki>
// WikiSyntaxTextMod:  Wiki syntax specific code
/* jshint curly:true, latedef:true, laxbreak:true,
          trailing:true, undef:true, white:false  */
/* global mw: true, mediaWiki: false                                   */
/*jslint plusplus: true, regexp: true, sloppy: true, unparam: true,
           vars: true, white: true, maxerr: 50 */
/*globals mw: true, mediaWiki: false                                   */


if (typeof(mediaWiki) !== "object") {   // disconnected
   mw  =  { config: false,
            libs:   { WikiSyntaxTextMod:  {debugging: false}
                    },
            log:    function () {}
          };
}
if (typeof(mw.libs.WikiSyntaxTextMod) !== "object") {   // isolated
   mw.libs.WikiSyntaxTextMod  =  { debugging: false };
}
if (typeof(mw.libs.WikiSyntaxTextMod.w) !== "object") {
   mw.libs.WikiSyntaxTextMod.w  =  { };
}
mw.libs.WikiSyntaxTextMod.w.vsn  =  -4.823;
if (typeof(mw.libs.WikiSyntaxTextMod.bb) !== "object") {
   mw.libs.WikiSyntaxTextMod.bb  =  { };
}



/*
(contracted; show full)   //    >< .text
   //    .w.chr.flushEntities()
   //    .w.chr.flushChars()
   //    .hooks.fire()
   //    .util.translate.factory()
   //    .o.WikiTom().replace()
   //    .w.elem.isbn.fire()
   // 2012-06-1
34 [email protected]
   var c;
   var t;
   var tms  =  [ ["([0-9])&(nbsp|#(160|x0*[aA]0));%",
                  "$1 %"],
                 ["&#x202[89];",
                  "\n"],
                 ["\n\\| *(border|(col|row)span) *= *(1?[0-9]) *\\|",
                  "\n|$1=\"$3\"|"],
                 ["\\bPMID"
                  + "(?::?&nbsp;)"
                  + "(?:| *: *)?"
                  + "([0-9]{6,10}[ /.,;)\n])",
                  "PMID $1"]
                ];
   if (WSTM.w.chr.detected.nbHyphen) {
      c    =  String.fromCharCode(8209);   // 2011 NON-BREAKING HYPHEN
      t    =  [   [c + "( |\n|<(br|div)\\b)",
                   "-$1"],
(contracted; show full)   //          [0] leading whitespace (standardized)
   //          [1] keyword
   //          [2] value (string content),  or false (sole)
   // Uses:
   //    >  .w.tags.reTagAttrQ
   //    >  .w.tags.reTagAttrX
   //    >  .w.tags.reTagAttrS

   //    >  .w.tags.reTagAttrE
   //    >  .w.tags.reTagAttrU
   //     < .mod.lazy
   //    .errors.found()
   //    .str.trim()
   // 2012-056-125 [email protected]
   var got   =  true;
   var p;
   var r     =  false;
   var set   =  false;
   var sign;
   var spc;
   var sub   =  " " + assign;
   var sum   =  "|";
   while (got) {
      sign  =  false;
      got   =  this.reTagAttrQ.exec(sub);
      if (got) {
         if (got[3]) {
            set  =  got[3];
         } else {
            set  =  got[4];
         }
         if (typeof(set) === "string") {
            set  =  WSTM.str.trim(set, true);
         } else {
            set  =  "";
         }
         if (! set.length) {
            WSTM.errors.found("tagAttrValueEmpty",
                              false,
                              "<" + about + " " + got[2] + "=\"\">");
            set  =  "???????";
         }
      } else {
         got  =  this.reTagAttrX.exec(sub);
         if (got) {
            if (got[3]) {
               set  =  got[3];
            } else if (got[4]) {
               set  =  got[4];
            } else {
               set  =  got[5];
            }
            WSTM.mod.lazy  =  false;
         } else {
            set  =  false;
            got  =  this.reTagAttrS.exec(sub + "/");
            if (! got) {
               sign  =  sub;
               got   =  this.reTagAttrE.exec(sub);
               if (got) {
                  sign  =  got[1];
                  WSTM.errors.found("tagAttrValueEmpty",
                                    false,
                                    "<" + about + " " + sign + "=>");
               } else {
               }
               spc  =  " ";
               set  =  "???";
               sub  =  " ";
               got  =  false;
            } else {
               got  =  this.reTagAttrU.exec(sub + "/");
               if (got) {
                  WSTM.errors.found("tagAttrInvalid",
                                    false,
                                    "<" + about + " " + assign);
                  set  =  sub;
               } else {
                  spc   =  " ";
                  sign  =  sub;
                  sub   =  "  ";
               }
            }
         }
      }
      if (got) {
         spc  =  got[1];
         p    =  spc.indexOf("\n");
(contracted; show full)   //    >  .w.tags.elt.parNone
   //    >  .w.tags.elt.unary
   //    >  .w.tags.elt.enclose
   //    >  .w.chr.detected.tab
   //     < .w.tags.blocks
   //     < .w.tags.reCommentBeg
   //     < .w.tags.reEndTags

   //     < .w.tags.reTagAttrE
   //     < .w.tags.reTagAttrQ
   //     < .w.tags.reTagAttrS
   //     < .w.tags.reTagAttrU
   //     < .w.tags.reTagAttrX
   //     < .w.tags.reTagBeg
   //     < .w.tags.reTagEnd
   //     < .w.tags.sealed
   //     < .w.tags.single
   //     < .w.tags.slice
   //     < .w.tags.sole
   //     < .w.tags.sources
   //     < .w.tags.stack
   //     < .w.tags.stop
   //     < .w.tags.storing
   //     < .w.tags.suckNowiki
   //     < .w.tags.suitable
   //    .o.WikiTom().find()
   //    .str.uniques()
   //    .o.WikiTom().fetch()
   //    .o.WikiTom().flip()
   //    .o.WikiTom().fresh()
   //    .o.WikiTom().frame()
   //    .w.tags.fold()
   //    .w.tags.frame()
   //    .errors.found()
   //    .o.WikiTom().fixTab()
   // Requires: JavaScript 1.3   fromCharCode()
   // 2012-06-015 [email protected]
   var got   =  all.find("<", 0, 0, true, false);
   var j;
   var k;
   var s     =  "([" + WSTM.w.chr.whitespace + "]+)?";
   var sqd   =  String.fromCharCode(34,8220,8221,8222);
   var sqs   =  String.fromCharCode(39,8216,8217,8218);
   var tag;
   var open  =  [ ];
   this.blocks        =  false;
   this.reCommentBeg  =  new RegExp("^" + s + "!--");
   this.reEndTags     =  { };
   this.reTagAttrE    =  new RegExp("\\b([^ =\n]+)[ \n]*=[ \n]*$");
   this.reTagAttrQ    =  new RegExp("^" + "( *\n *| +)"
                                        + "([a-z_A-Z:0-9]+)"
                                        + " *\n? *= *\n? *"
                                        + "(?:'([^'\n]*)'"
                                          + "|\"([^\"\n]*)\""
                                        + ")");
(contracted; show full)
// Emacs
// Local Variables:
// encoding: iso-8859-1-dos
// fill-column: 80
// End:

/// EOF </nowiki>   WikiSyntaxTextMod/?W.js