/** * HTML編集のショートカットをココに集めて使います * @author ヘルプの人 */ var f = classes["html"]; /** * 一行入力ダイアログが動いたときの処理モードを指定 * 0:デフォルト * 1:HTML入力変換 * 2:HTMLライン入力 */ var EvalBufferMode = 0; /* helpメッセージを表示するかどうかを指定 trueで表示 */ var bflag = true; /** * Chtl+Shift+何か他のキー、を同時押しした場合、指定のマクロを呼び出して実行します * arg 押されたキーを配列として出します。弄るべからす! * classname 自分の追加されたクラス名。弄るべからす! * methodname 実行するメソッド名。弄るべからす! */ /** * 各行の前後にpタグを入れ込みます */ f.change_p = function(){ var c = App.Caret; var slct = App.Caret.Selection; var ctx = c.BeginUpdate(); try { c.BeginOperateGroup('各行にpタグを追加'); try { if( slct.Mode ){ var tStr = slct.Text.replace( /(\t*)(.*)(\n)/g, "$1

$2

$3" ).replace( /

([\s]*)<\/p>/g, "$1
" ); c.Delete( tStr.length ); c.Send( tStr ); } } catch( e ){App.Alert( e ); } finally{ c.EndOperateGroup(); } } catch( e ){ App.Alert( e ); } finally{ c.EndUpdate(ctx); } } /** * 行末にbrタグを入れ込みます */ f.change_br = function(){ var c = App.Caret; var ctx = c.BeginUpdate(); c.BeginOperateGroup('マクロ:br変換'); try { var slct = App.Caret.Selection; if( slct.Mode ){ var tStr = slct.Text.replace( /(\t*.+)(\n)/g, "$1
$2" ); c.Delete( tStr.length ); c.Send( tStr ); } } finally { c.EndOperateGroup(); } } /** * タブで区切られたテキストを、行ごとにテーブルのセルに置換します */ f.change_table = function(){ var c = App.Caret; var slct = App.Caret.Selection; var ctx = c.BeginUpdate(); try { c.BeginOperateGroup('タブ区切りをテーブルに変換'); try { if( slct.Mode ){ var tStr = slct.Text; // temporary string c.Delete( tStr.length ); var _tab = tStr.match( /(^\t*)/ )[1]; // 最初の行のタブを取得 tStr = tStr.replace( /\t/g, "" ); tStr = tStr.replace( /^(<\/td>)+/, _tab ); // 行頭マッチ"^"の動作がオカシイので変な書き方で逃げる tStr = tStr.replace( /(\t*)(.+)(\n)/g, "$1$2$3" ); c.Send( tStr ); } } finally { c.EndOperateGroup(); } } catch( e ){ App.Alert( e ); } finally { c.EndUpdate(ctx); } } /** 各行を、liタグで挟み込んでしまいます */ f.change_li = function() { var c = App.Caret; var ctx = c.BeginUpdate(); try { c.BeginOperateGroup('各行をLIタグで囲い込み'); try { var slct = c.Selection; if( slct.Mode ){ var tStr = slct.Text; c.Delete( tStr.length ); c.Send( tStr.replace( /(\t*)(.+)(\n)/g, "$1

  • $2
  • $3" ) ); } } finally { c.EndOperateGroup(); } } finally { c.EndUpdate(ctx); } } /** * クリップボードに残った、テキストをファイル名として、IMGタグを挿入します */ f.set_imgtag = function(){ var c = App.Caret; var ctx = c.BeginUpdate(); try { c.BeginOperateGroup('マクロ:IMGタグの挿入'); try { c.Send("" ); } finally { c.EndOperateGroup(); } } finally { c.EndUpdate(ctx); } } /** * Bタグ補完 */ f.onKeyB = function (arg, classname, methodname) { ( (KEYMASK_SHIFT | KEYMASK_CTRL) == (arg & KEYMASK) )? this.change_br(): invoke(arg, this.parent, methodname); } /** * liタグ補完 */ f.onKeyL = function (arg, classname, methodname) { ( (KEYMASK_SHIFT | KEYMASK_CTRL) == (arg & KEYMASK) )? this.change_li(): invoke(arg, this.parent, methodname); } /** * imgタグ補完 */ f.onKeyN = function (arg, classname, methodname) { ( (KEYMASK_SHIFT | KEYMASK_CTRL) == (arg & KEYMASK) )? this.set_imgtag(): invoke(arg, this.parent, methodname); } /** * tableタグ補完 */ f.onKeyT = function (arg, classname, methodname) { ( (KEYMASK_SHIFT | KEYMASK_CTRL) == (arg & KEYMASK) )? this.change_table(): invoke(arg, this.parent, methodname); } /** * pタグ補完 */ f.onKeyP = function (arg, classname, methodname) { ( (KEYMASK_SHIFT | KEYMASK_CTRL) == (arg & KEYMASK) )? this.change_p(): invoke(arg, this.parent, methodname); } /** * ZenCodingモード */ f.onKeyX = function (arg, classname, methodname) { function baloon(){ if( !bflag ) return; App.Balloon( 'HTMLタグ補完をします。入力したいタグ名を入れてください\n'+ 'div :
    \n'+ 'div.className :
    \n'+ 'div#idName :
    \n' ); } if( (KEYMASK_SHIFT | KEYMASK_CTRL) == (arg & KEYMASK) ){ this.EvalBufferMode = 1; // 処理モードを指定、1はHTML変換モード; //baloon(); App.Window.InputStyle = 2; // 画面上の一行入力ボックスに移動 return; } invoke(arg, this.parent, methodname); } f.onKeyC = function (arg, classname, methodname) { if( (KEYMASK_SHIFT | KEYMASK_CTRL) == (arg & KEYMASK) ){ EvalBufferMode = 2; // 処理モードを指定、2はHTML変換モード; App.Window.InputStyle = 2; // 画面上の一行入力ボックスに移動 return; } invoke(arg, this.parent, methodname); } /** * タグの間を移動するための関数。移動方法は…一言では言いにくい(汗 */ f.jump_right = function (arg, classname, methodname) { var c = App.Caret; var i=0; // 単語間の移動回数をカウントしています switch ( c.LexState.State ){ case 1: if( "<" != c.Char ){ // タグの外から開始位置まで移動 do c.MoveRight(1); while( !c.Char.match(/[<]/) && c.LexState.State < 11 && ++i<300 ); break; } c.MoveRight(1); case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: i=0; do c.MoveRightWordBound( 0 ); while( c.LexState.State<10 && ++i<30 ); // attributeの"="まで移動 ('/'==c.Char)?c.MoveRight(1):''; //
    のスラッシュ"/"などに反応 c.Char.match(/>/)?c.MoveRight(1):''; // タグの終了">"に反応 break; case 11: do c.MoveRightWordBound( 0 ); while( c.LexState.State!=1 && c.LexState.State!=11 && ++i<30 ); // attributeの"="かタグの終了まで移動 ('/'==c.Char)?c.MoveRight(1):''; c.Char.match(/>/)?c.MoveRight(1):''; break; case 12: case 13: case 14: case 15: do c.MoveRightWordBound( 0 ); while( !c.Char.match(/["']/) && ++i<30 ); break; default: c.MoveRightWordBound( 0 ); } } /** * タグを一挙選択するための関数 */ f.select_right = function (arg, classname, methodname) { var c = App.Caret; c.Selection.Mode = 1; var i=0; // 単語間の移動回数をカウントしています switch ( c.LexState.State ){ case 1: if( "<" != c.Char ){ do c.MoveRight(1); while( !c.Char.match(//) && ++i<300 ); c.MoveRight(1); } // タグの範囲"<"~">"までを選択 break; case 2: case 3: case 4: case 5: do c.MoveRight(1); while( !c.Char.match(/>/) && c.LexState.State<6 && ++i<300 ); break; case 6: case 7: var lFlag = false; // コメント部分"~"を通過したかチェック do { c.MoveRight(1); if( lFlag && c.LexState.State<12 ) return; if( !lFlag ){ lFlag = ( 12のスラッシュ"/"などに反応 c.Char.match(/>/)?c.MoveRight(1):""; // タグの終了">"に反応 break; case 11: c.Selection.Mode = 0; do c.MoveLeft(1); while( !c.Char.match(/[\s]/) && ++i<30 ); // attributeの"="まで移動 c.Selection.Mode = 1; var lFlag = false; // コメント部分"~"を通過したかチェック do { c.MoveRight(1); if( lFlag && c.LexState.State<12 ) return; if( !lFlag ){ lFlag = ( 12/).test(c.Char) && !i ) break; // タグの内部に入ったハズなのに注意 if( (/>/).test(c.Char) ) return c.MoveRight(1); // 普通の終了方法。タグの終了位置を発見した事による終了 } while( ++i<300 ); // 最後にbreak文無いのに注意! case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: do { c.MoveLeft(1); if( ((/0)?1:0), order ); while( num.length < order ) num = '0'+num; return num; } // HTMLタグのデータ var ElementsData={ body:'block', blockquote:'block', center:'block', colgroup:'block', comment:'block', dd:'block', dl:'block', dir:'block', div:'block', fieldset:'block', form:'block', frame:'block', frameset:'block', head:'block', html:'block', iframe:'block', map:'block', marquee:'block', menu:'block', multicol:'block', 'object':'block', ol:'block', optgroup:'block', plaintext:'block', pre:'block', script:'block', select:'block', style:'block', table:'block', tbody:'block', thead:'block', ul:'block', code:'line', dt:'line', p:'line', li:'line', option:'line', h1:'line', h2:'line', h3:'line', h4:'line', h5:'line', h6:'line', tr:'line', th:'line', textarea:'line', title:'line' }; // 記号以外の基本文字列 var BaseChar='A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u0131\u0134-\u013E\u0141-\u0148\u014A-\u017E\u0180-\u01C3\u01CD-\u01F0\u01F4-\u01F5\u01FA-\u0217\u0250-\u02A8\u02BB-\u02C1\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03CE\u03D0-\u03D6\u03DA\u03DC\u03DE\u03E0\u03E2-\u03F3\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E-\u0481\u0490-\u04C4\u04C7-\u04C8\u04CB-\u04CC\u04D0-\u04EB\u04EE-\u04F5\u04F8-\u04F9\u0531-\u0556\u0559\u0561-\u0586\u05D0-\u05EA\u05F0-\u05F2\u0621-\u063A\u0641-\u064A\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D3\u06D5\u06E5-\u06E6\u0905-\u0939\u093D\u0958-\u0961\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8B\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AE0\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B36-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB5\u0BB7-\u0BB9\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D60-\u0D61\u0E01-\u0E2E\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EAE\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0F40-\u0F47\u0F49-\u0F69\u10A0-\u10C5\u10D0-\u10F6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110B-\u110C\u110E-\u1112\u113C\u113E\u1140\u114C\u114E\u1150\u1154-\u1155\u1159\u115F-\u1161\u1163\u1165\u1167\u1169\u116D-\u116E\u1172-\u1173\u1175\u119E\u11A8\u11AB\u11AE-\u11AF\u11B7-\u11B8\u11BA\u11BC-\u11C2\u11EB\u11F0\u11F9\u1E00-\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u212E\u2180-\u2182\u3041-\u3094\u30A1-\u30FA\u3105-\u312C\uAC00-\uD7A3'; // 一部の記号 var Ideographic = '\u4E00-\u9FA5\u3007\u3021-\u3029'; // 数字 var Digit = '0-9\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE7-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29'; var Extender = '\u00B7\u02D0\u02D1\u0387\u0640\u0E46\u0EC6\u3005\u3031-\u3035\u309D-\u309E\u30FC-\u30FE'; // 名前の定義 var Letter = BaseChar+Ideographic; var NameChar = Letter+Digit+Extender+'\-\_:\\$'; var Name = '['+Letter+'_:]['+NameChar+']*'; // 属性値 var EntityValue='(?:"[^"]*?"|\'[^\'*?]\'|\\w+)'; var Tag = '('+Name+')?((?:[#\\.]'+Name+')+)?((?:\s*\\[.*?\\])+)?((?:\\s+'+Name+'=(?:"[^"]+?"|\'[^\']+?\'|\\S+))+)?({.*?})?'; var parser={ '^(\\s*\\(\\s*)':function( s ){ return '('; }, // 『(』演算子 '^(\\s*\\)\\s*)':function( s ){ return ')'; }, // 『)』演算子 '^(\\s*>\\s*)':function( s ){ return '>'; }, // 『>』演算子 '^(\\s*\\+\\s*)':function( s ){ return '+'; }, // 『+』演算子 '^(\\s*\\*\\s*)':function( s ){ return '*'; } // 『*』演算子 }; parser['^\\s*([0-9]+)\\s*']=function( s ){ return s.match(new RegExp('^\\s*([0-9]+)\\s*'))[1]; } // 『数値』演算子 parser['^\\s*('+Tag+')']=function( s ){ return s.match(new RegExp('^\\s*('+Tag+')'))[1]; }; // タグ名 var lang='ja'; // よく使うタグをスニペットで変換 var snippets={ 'a':function(attr){ return ['','']; }, 'a:mail':function(attr){ return ['','']; }, 'abbr':function(attr){ return ['','']; }, 'acronym':function(attr){ return ['','']; }, 'acr':function(attr){ return ['','']; }, 'ac':function(attr){ return ['','']; }, 'adr':function(attr){ return ['\n','\n']; }, 'base':function(attr){ return ['\n','']; }, 'blockquote':function(attr){ return ['
    \n','
    \n']; }, 'bq':function(attr){ return ['
    \n','
    \n']; }, 'body:ie':function(attr){ return ['\n\n\n\n','\n']; }, 'body:cc':function(attr){ return ['\n\n\n\n','\n']; }, 'q:cite':function(attr){ return ['','']; }, 'bdo':function(attr){ return ['','']; }, 'bdo:l':function(attr){ return ['','']; }, 'bdo:r':function(attr){ return ['','']; }, 'del':function(attr){ return ['','']; }, 'ins':function(attr){ return ['','']; }, 'style':function(attr){ return ['\n']; }, 'script':function(attr){ return ['\n']; }, 'sc':function(attr){ return ['\n']; }, 'script:cdata':function(attr){ return['\n']; }, 'script:src':function(attr){ return['\n']; }, 'script:jquery':function(){ return ['']; }, 'script:jqueryui':function(){ return ['']; }, 'script:validate':function(){ return ['']; }, 'script:swf':function(){ return ['']; }, 'img':function(attr){ return ['','']; }, 'iframe':function(attr){ return ['\n']; }, 'ifr':function(attr){ return ['\n']; }, 'object':function(attr){ return ['\n','\n']; }, 'obj':function(attr){ return ['\n','\n']; }, 'embed':function(attr){ return ['\n', '']; }, 'emb':function(attr){ return ['\n','']; }, 'param':function(attr){ return ['\n','']; }, 'map':function(attr){ return ['\n','\n']; }, 'area':function(attr){ return ['\n','']; }, 'area:default':function(attr){ return ['\n','']; }, 'area:d':function(attr){ return ['\n','']; }, 'area:rect':function(attr){ return ['\n','']; }, 'area:r':function(attr){ return ['\n','']; }, 'area:poly':function(attr){ return ['\n','']; }, 'area:p':function(attr){ return ['\n','']; }, 'cap':function(attr){ return ['\n','\n']; }, 'fset':function(attr){ return ['\n','\n']; }, 'fld':function(attr){ return ['\n','\n']; }, 'col':function(attr){ return ['\n','']; }, 'colg':function(attr){ return ['\n','\n']; }, 'br':function(attr){ return ['','']; }, 'hr':function(attr){ return ['\n','']; }, 'link':function(attr){ return ['\n','']; }, 'link:css':function(attr){ return ['\n','']; }, 'link:print':function(attr){ return ['\n','']; }, 'link:favicon':function(attr){ return ['\n','']; }, 'link:fav':function(attr){ return ['\n','']; }, 'link:rss':function(attr){ return ['\n','']; }, 'link:atom':function(attr){ return ['\n','']; }, 'link:start':function(attr){ return ['\n','']; }, 'link:next':function(attr){ return ['\n','']; }, 'link:prev':function(attr){ return ['\n','']; }, 'link:contents':function(attr){ return ['\n','']; }, 'link:index':function(attr){ return ['\n','']; }, 'link:copyright':function(attr){ return ['\n','']; }, 'link:copy':function(attr){ return ['\n','']; }, 'link:glossary':function(attr){ return ['\n','']; }, 'link:chapter':function(attr){ return ['\n','']; }, 'link:section':function(attr){ return ['\n','']; }, 'link:subsection':function(attr){ return ['\n','']; }, 'link:appendix':function(attr){ return ['\n','']; }, 'link:help':function(attr){ return ['\n','']; }, 'link:bookmark':function(attr){ return ['\n','']; }, 'link:jetpack':function(attr){ return ['\n','']; }, 'link:touch':function(attr){ return ['\n','']; }, 'link:home':function(attr){ return ['\n','']; }, 'link:top':function(attr){ return ['\n','']; }, 'link:origin':function(attr){ return ['\n','']; }, 'link:child':function(attr){ return ['\n','']; }, 'link:previous':function(attr){ return ['\n','']; }, 'link:prev':function(attr){ return ['\n','']; }, 'link:toc':function(attr){ return ['\n','']; }, 'link:search':function(attr){ return ['\n','']; }, 'link:find':function(attr){ return ['\n','']; }, 'link:author':function(attr){ return ['\n','']; }, 'link:last':function(attr){ return ['\n','']; }, 'link:up':function(attr){ return ['\n','']; }, 'link:parent':function(attr){ return ['\n','']; }, 'link:first':function(attr){ return ['\n','']; }, 'link:begin':function(attr){ return ['\n','']; }, 'link:made':function(attr){ return ['\n','']; }, 'meta':function(attr){ return ['\n','']; }, 'meta:js':function(attr){ return ['\n','']; }, 'meta:css':function(attr){ return ['\n','']; }, // charsetを指定忘れている 'meta:charset':function(attr){ return ['\n','']; }, 'meta:utf':function(attr){ return ['\n','']; }, 'meta:win':function(attr){ return ['\n','']; }, 'meta:sjis':function(attr){ return ['\n','']; }, 'meta:description':function(attr){ return ['\n','']; }, 'meta:desc':function(attr){ return ['\n','']; }, 'meta:robots':function(attr){ return ['\n','']; }, 'meta:compat':function(attr){ return ['\n','']; }, 'meta:ie7':function(attr){ return ['\n','']; }, 'meta:ie8':function(attr){ return ['\n','']; }, 'meta:emuie7':function(attr){ return ['\n','']; }, 'meta:nocache':function(attr){ return ['\n','']; }, 'form':function(attr){ return ['
    \n','
    \n']; }, 'form:get':function(attr){ return ['
    \n','
    \n']; }, 'form:post':function(attr){ return ['
    \n','
    \n']; }, 'form:file':function(attr){ return ['
    \n','
    \n']; }, 'label':function(attr){ return ['']; }, 'button':function(attr){ return ['']; }, 'button:reset':function(attr){ return ['']; }, 'button:r':function(attr){ return ['']; }, 'button:submit':function(attr){ return ['']; }, 'button:s':function(attr){ return ['']; }, 'select':function(attr){ return ['\n']; }, 'select:multi':function(attr){ return ['\n']; }, 'optgroup':function(attr){ return ['\n','\n']; }, 'optg':function(attr){ return ['\n','\n']; }, 'option':function(attr){ return ['\n']; }, 'opt':function(attr){ return ['\n']; }, 'op':function(attr){ return ['\n']; }, 'textarea':function(attr){ return ['\n']; }, 'input':function(attr){ return ['\n','']; }, 'input:hidden':function(attr){ return ['\n','']; }, 'input:h':function(attr){ return ['\n','']; }, 'input:text':function(attr){ return ['\n','']; }, 'input:t':function(attr){ return ['\n','']; }, 'input:password':function(attr){ return ['\n','']; }, 'input:p':function(attr){ return ['\n','']; }, 'input:checkbox':function(attr){ return ['\n','']; }, 'input:c':function(attr){ return ['\n','']; }, 'input:radio':function(attr){ return ['\n','']; }, 'input:r':function(attr){ return ['\n','']; }, 'input:submit':function(attr){ return ['\n','']; }, 'input:s':function(attr){ return ['\n','']; }, 'input:image':function(attr){ return ['\n','']; }, 'input:img':function(attr){ return ['\n','']; }, 'input:i':function(attr){ return ['\n','']; }, 'input:button':function(attr){ return ['\n','']; }, 'input:btn':function(attr){ return ['\n','']; }, 'input:b':function(attr){ return ['\n','']; }, 'input:file':function(attr){ return ['\n','']; }, 'input:f':function(attr){ return ['\n','']; }, 'input:reset':function(attr){ return ['\n','']; }, // 言語コード認識なし 'html:xml':function(attr){ return ['\n','\n']; }, 'html:4t':function(attr){ return ['\n \n\t\n\t\n \n\n','\n\n']; }, 'html:4s':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html:4f':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html:4':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html4':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html:5':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html5':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html:xt':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'xhtml:t':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html:xs':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'xhtml:s':function(attr){ return ['\n \n\t\n\t\n \n\n','\n\n']; }, 'xhtml:1':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'xhtml1':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html:xf':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'xhtml:f':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'html:xxs':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'xhtml:11':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'xhtml11':function(attr){ return ['\n\n \n\t\n\t\n \n\n','\n\n']; }, 'xml:version':function(attr){ return ['','']; }, 'comment':function(attr){ return ['']; }, 'cc':function(attr){ return ['\n']; }, 'cc:ie':function(){ return ['\n']; }, 'cc:noie':function(){ return ['\n','\n']; }, 'cc:notie':function(){ return ['\n','\n']; }, 'cc:ie6':function(){ return ['\n']; }, 'cc:ie7':function(){ return ['\n']; }, 'cc:ie8':function(){ return ['\n']; }, 'cc:ie9':function(){ return ['\n']; }, 'cc:ltie6':function(){ return ['\n']; }, 'cc:ltie7':function(){ return ['\n']; }, 'cc:ltie8':function(){ return ['\n']; }, 'cc:ltie9':function(){ return ['\n']; }, 'cc:gtie6':function(){ return ['\n']; }, 'cc:gtie7':function(){ return ['\n']; }, 'cc:gtie8':function(){ return ['\n']; }, 'cc:gtie9':function(){ return ['\n']; }, 'cc:lteie6':function(){ return ['\n']; }, 'cc:lteie7':function(){ return ['\n']; }, 'cc:lteie8':function(){ return ['\n']; }, 'cc:lteie9':function(){ return ['\n']; }, 'cc:gteie6':function(){ return ['\n']; }, 'cc:gteie7':function(){ return ['\n']; }, 'cc:gteie8':function(){ return ['\n']; }, 'cc:gteie9':function(){ return ['\n']; } }; // タグの書式部分の解析 function ParseTag( s, idx, inContent ){ idx = ( 'number'!=typeof idx )?1:idx+1; var m = s.match(new RegExp(Tag)); if(!m) return; m[1]=m[1]?m[1]:'div'; // タグ名が無い場合は勝手にdivタグと推測 var attr = ''; // ID、クラス名の変換 var idmc = new RegExp('#('+Name+')'); if( undefined!=m[2] ) attr+=m[2] .replace( idmc, ' id="$1"' ) .replace( new RegExp('\\.('+Name+'\\.?)+'), function(mh){ return ' class="'+mh.split('.').join(' ').replace(/.*/,function($){ return $.slice(1,$.length); })+'"'; } ); // a[title] 等の書式の変換 if(m[3]) attr+=m[3].replace( new RegExp('\\s*\\[(.+?)\\]', 'g'), function($1,$2){ var r=/(.+?)=("(?:.*?)"|'(?:.*?)'|(?:\S*)?)/; return $2.match(r) ? $2.replace( r, ' $1=$2' ):' '+$2+'=""'; } ); // a title='' 等の書式の変換 if(m[4]) attr+=m[4].replace( new RegExp('\\s('+Name+')=([^\'"]\\S+)', 'g'), ' $1="$2"' ); // タグの情報を引き出す var blk = ElementsData.hasOwnProperty(m[1].toLowerCase()) ? ElementsData[m[1].toLowerCase()]: ''; // タグ内部にテキストの挿入 var inner = m[5] ? m[5].match(/{(.*?)}/)[1] : ''; inner = inner.replace( /\$+/g, function( $1 ){ return ( 1==$1.length ) ? idx : num2str( idx, $1.length ); } ); if( inContent ) inner += (function(type){ var inner='', arr = $.split('\n'); if ( 'block'==type ){ inner = $.replace( /(.*)\n/g, '\t$1\n' ); $ = ''; } else { inner = arr.shift(); $ = arr.join('\n'); } return inner; })( blk ); var tag=[ '<'+m[1]+attr+'>'+(('block'==blk)?'\n':''), inner, ''+(('block'==blk||'line'==blk)?'\n':''), ]; // スニペットを使ってよく使うタグのデータを変更する (function transSnippets( i ){ if( !snippets.hasOwnProperty( i ) ) return; var r = snippets[i]( attr ); tag[0]=r[0]; tag[2]=r[1]; })(m[1]); // 「$」を数字に変換 tag[0]=tag[0].replace( /\$+/g, function( $1 ){ return ( 1==$1.length ) ? idx : num2str( idx, $1.length ); } ); return tag; } // 字句解析 var s=this.toString(); // トークン切り出し var tkstack=(function token_getter(){ var tkstack=[], cnt=0; continue_parse: while(s){ // 全文がマッチするまで解析を続ける for( var i in parser ){ if(++cnt>200) break continue_parse; // マッチするまでcontinueで繰り返す if( !parser.hasOwnProperty(i) ) continue; var m = s.match( new RegExp(i) ); if(null==m) continue; // マッチした構文をスタックに積む s = s.slice( m[0].length, s.length ); tkstack.push( parser[i](m[0]) ); continue continue_parse; } // すべてのマッチに失敗するとundefined return undefined; } return tkstack; })(s); /** * 構文木の生成(括弧の処理) */ var stk=(function parse( stk, rstk ){ var itm; while( itm=stk.shift() ){ if( ')'==itm ) return rstk; if( '('==itm ){ rstk.push(parse( stk, [] )); continue; } rstk.push(itm); } return rstk; })(tkstack, []); // 「*」の処理:タグの繰り返し function tagTimes( s, times, inContent ){ var tag = [], rt=[]; if( s instanceof Array ) tag=Expr(s); for( var i=0; i':function( befItm ){ var rt=[], tag=[], s=Expr( stk ); for( var i=0; i