/************************************

  "waka" is a Japanese poetry 
         composed of 31 syllables. 

  (c) 2005 Pixel-Apes.

  -----------------------------------

  Decoration markup:
  
  **bold**
  //italic//
  ##monospace##
  __underline__

  <[ blockquotes ]>

*************************************/



function wakaDecoration() {}
         wakaDecoration.prototype = new wakaToken();
         wakaDecoration.prototype.constructor = 
         wakaDecoration;

// static
wakaDecoration.prototype.getRegexpPart = function()
{
  return "(\\*\\*(.)*?\\*\\*)"+
         "|"+
         "(\\/\\/(.)*?\\/\\/)"+
         "|"+
         "(__(.)*?__)"+
         "|"+
         "(##(.)*?##)"+
         "|"+
         "(\\+\\+(.)*?\\+\\+)"+
//         "|"+
//         "(>>(.)*?<<)"+     // buggish one
         "|"+
         "(<\\[(.|\n)*?\\]>)";
}
                                 //12                  3
wakaDecoration.prototype.isRE  = /^((\*|\/|\+|#|_){2})(.*)\1$/;
                                 //1  2
wakaDecoration.prototype.isRE2 = /^(>>(.*)<<)$/;
                                 //1   23
wakaDecoration.prototype.isRE3 = /^(<\[\s+((.|\n)*)\s+\]>)$/;
wakaDecoration.prototype.is = function( outerText )
{
  var matches = this.isRE.exec( outerText );
  if (matches !== null) 
    return {
            inner : matches[3],
            type  : matches[2],
            text  : outerText
           };

  /*
  var matches = this.isRE2.exec( outerText );
  if (matches !== null) 
    return {
            inner : matches[2],
            type  : ">>",
            text  : outerText
           };
  */
  var matches = this.isRE3.exec( outerText );
  if (matches !== null) 
    return {
            inner : matches[2],
            type  : "<[",
            text  : outerText
           };
           
  return false;
}



// private (compilation)
wakaDecoration.prototype.tagMap = { "/"  : "i",  "*" : "b", "+" : "small", 
                                    "#"  : "tt", "_" : "u", 
                                    ">>" : "center",
                                    "<[" : "blockquote" };
wakaDecoration.prototype._compile   = function()
{
  var tag = this.tagMap[ this._data.type ];
  var inner = this.wf.format( this._data.inner, "default" );
  this._html = "<"+tag+">"+ inner +"</"+tag+">";
}







