Difference between revisions 137705 and 137843 on testwiki

/// PerfektesChaos/js/WikisyntaxTextMod/?W.js
/// 2012-06-18 [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                                   */
(contracted; show full)                  s  =  WSTM.str.setChar(s, "&thinsp;", i);
                  l  =  true;
                  break;
               case 8203 : // ZERO WIDTH SPACE used in bo:
                  s  =  WSTM.str.setChar(s, "&#x200A;", i);
                  l  =  true;
                  break;
               case 8204 : // ZERO WIDTH NON-JOINER used in 
Farsi, kfa: kn: mzn:
                  s  =  WSTM.str.setChar(s, "&zwnj;", i);
                  l  =  true;
                  break;
               case 8205 : // ZERO WIDTH JOINER      used in ml:
                  s  =  WSTM.str.setChar(s, "&zwj;", i);
                  l  =  true;
                  break;
(contracted; show full)      case   91 : // [ lsqb
      case   93 : // ] rsqb
      case  123 : // { lcub
      case  124 : // | verbar
      case  125 : // } rcub
         r  =  false;
      /* special chars to be deleted one day */
      case 8204 : // zwnj   // required in Farsi, kn:
, mzn:
      case 8205 : // zwj    // required in ml:
         r  =  0;
         break;
      /* to be replaced by ASCII space */
      case 8194 : // ensp
      case 8195 : // emsp
         r  =  32;
(contracted; show full)   // Uses:
   //    .util.fiatObjects()
   // 2012-05-25 [email protected]
   WSTM.util.fiatObjects(WSTM.w,  "tags",  { });




      WSTM.w.tags.elt  =  { banned:     "a|applet|area|audio"
                                     + "|base|body|button"
                                        + "|command|embed"
                                     + "|form|frame|frameset"
                                        + "|head|html"
                                     + "|iframe|img|input|isindex"
                                        + "|layer|link|map|meta"
                                     + "|object|option"
                                        + "|script|select|style"
                                     + "|textarea|title"
                                        + "|xml",
                            binary:     "blockquote|center|code|dfn|gallery"
                                        + "|hiddentext|hiero|imagemap"
"
                                     + "|imagemap|includeonly|inputbox"
                                     + "|kbd|noinclude"
                                        + "|onlyinclude|poem|pre"
                                        + "|ruby|rb|rbc|rp|rt|rtc|samp",
                            blockEnd:   "gallery|imagemap|inputbox|pre"
                                        + "|references",
                            codeBlock:  "pre",
                            codeData:   "hiero|imagemap|inputbox|math|poem"
                                        + "|timeline",
                            codedFix:   "syntaxhighlight|source",
                            codeInline: "code|dfn|kbd|poem|samp",
                            comment:    "hiddentext",
                            direct:     "bdi|br|ref|hiddentext"
                                        + "|ruby|rb|rbc|rp|rt|rtc",
                            enclose:    "b|big|blockquote|center|i|em"
                                        + "|s|span|strong|u",
                            marker:     "gallery|includeonly|onlyinclude"
                                        + "|references",
                            parNone:    "hiddentext"
                                     + "|imagemap|includeonly"
|inputbox"
                                     + "|inputbox|noinclude|nowiki"
|onlyinclude"
                                     + "|onlyinclude|rb|rbc|rp|rt|rtc|ruby"
                                        + "|timeline",
                            parWith:    "bdi|br|code|dfn|div|gallery|hiero|kbd"
"
                                     + "|kbd|math|pages|poem|pre"
                                     + "|ref|references"
                                        + "|samp|small|source|span|sub|sup"
                                        + "|syntaxhighlight|tt",
                            unary:      "br|hr"
                          };   // 2012-06-05
      WSTM.w.tags.pars  =  { gallery:    "caption=|class=|heights=|perrow="
                                         + "|showfilename|style=|widths=",
                             ref:        "!|name=|group=|follow=",
                             references: "group="
                           };   // 2012-06-18



WSTM.w.tags.feature  =  function (arglist, access, adjust, assign) {
   // Retrieve particular tag parameter value, and/or set value
   // Precondition:
   //    arglist  -- tag object
(contracted; show full)   //    >  .w.chr.whitespace
   //    >< .w.tags.reEndTags
   //    .o.WikiTom().find()
   //    .o.WikiTom().fetch()
   //    .o.WikiTom().flip()
   //    .errors.found()
   // Requires: JavaScript 1.3   charCodeAt()
   // 2012-0
4-146-20 [email protected]
   var lbb  =  false;
   var lbe  =  false;
   var leb  =  false;
   var lee  =  false;
   var i;
   var j;
   var k;
   var m;
   var n;
   var r;
   var s;
   var re    =  this.reEndTags[arglist.scope];
   if (! re) {
      re  =  "[" + WSTM.w.chr.whitespace + "]*";
      re  =  "(<" + re + "[/\\\\]" + re + arglist.scope + re + ">)" +
             "(\n|<!--)?";
      re  =  new RegExp(re, "i");
      this.reEndTags[arglist.scope]  =  re;
   }
   r  =  all.find( [re, 1],
                   arglist.join + arglist.move,
                   arglist.node,
                   true,
                   false );
   if (r) {
      j  =  arglist.join;
      m  =  0;
      i  =  r.i;
      n  =  r.r[1].length;
      k  =  i - j - arglist.move - 1;
      s  =  "";
      if (arglist.limited) {
         j  =  (j  ?  j - 1  :  0);
         m  =  j - arglist.join + arglist.move + 3;
         s  =  all.fetch(arglist.node, j, false);
         k  =  i - j;
         s  =  s.substr(0, k);
         if (arglist.join) {
            lbb  =  (s.charCodeAt(0) !== 10);
         }
         lbe  =  (s.charCodeAt(m + 1)  !==  10);
         }
         leb  =  (s.charCodeAt(s.length - 1)  !==  10);
         lee  =  (typeof(r.r[2]) !== "string");
         if (lbb || lbe) {
            n  +=  k;
            i   =  j;
            if (lbe) {
               s   =  s.substr(0,  m + 1)   +  "\n"  +   s.substr(m + 1);
               k++;
(contracted; show full)      }
   }
   if (! l) {
      arglist.move  +=  2;
   }
   if (arglist.limited) {
      this.free(all, arglist);
      if (arglist.scope === "references") {
   // imagemap
         if (arglist.lone  ||  ! arglist.leader) {
            if (this.references) {
               WSTM.errors.found("tagNestingSelf",
                                 false,
                                 "<" + arglist.scope + ">");
            } else if (! arglist.lone) {
               this.references  =  WSTM.w.elem.refgroups(arglist);
            }
         } else {
            this.references  =  false;
         }
      }
   }
   if (! arglist.lone) {
      if (this.slice.indexOf(arglist.scan) >= 0) {
         if (! lapsus) {
            arglist.mode  =  (arglist.leader ? WSTM.o.WikiTom.TagEnd
                                             : WSTM.o.WikiTom.TagBegin);
            l             =  (arglist.scope !== "ref");
         }
      }
   }
   if (this.spacing.indexOf(arglist.scan) >= 0) {
      this.flow(all, arglist);
   }
   if (l) {
      p  =  all.folder(arglist.join,
                       arglist.node,
                       arglist.join + arglist.move,
                       arglist.node);
      if (p) {
         p.mode     =  arglist.mode;
         p.limited  =  arglist.limited;
         p.lookup   =  arglist.lookup;
         if (arglist.join) {////////////////////     ||  ! arglist.node
            arglist.node++;
            arglist.join  =  0;
         }
         if (arglist.mode === WSTM.o.WikiTom.TagEnd) {
            m  =  (m ? --m : 0);
            l  =  (arglist.scope === "includeonly"  ||
                   arglist.scope === "onlyinclude");
(contracted; show full)
// Emacs
// Local Variables:
// encoding: iso-8859-1-dos
// fill-column: 80
// End:

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