html HTML整形ツールのPHPソース By admin 27 8月, 2014 11件のコメント HTML整形ツールのPHPソースです。 ロジックを確認されたい方は参考にしてみてください。 <?php //============================================================================// // html 整形 create 2007/09/12 update 2013/01/27 t.ohishi // //============================================================================// //初期セット $msg="HTMLを貼り付けてください。"; $after=""; //入力値を受け取る $before=stripslashes(@$_POST["before"]); if($before==""){ $before=$msg; } $IndentType=stripslashes(@$_POST["IndentType"]); if($IndentType==""){ $IndentType="3"; } $DebugTag=stripslashes(@$_POST["DebugTag"]); if($DebugTag==""){ $DebugTag=""; } $ipaddr=$_SERVER["REMOTE_ADDR"]; $host=gethostbyaddr_timeout1($ipaddr); setlocale(LC_TIME,"Japanese_Japan.932"); $date=gmdate('Ym',strtotime("+9 hours")); $file_name="log/hhlog$date.log"; $file=fopen($file_name,"a") or die("OPENエラー $file_name"); flock($file,LOCK_EX); $string=gmdate('Y/m/d H:i:s',strtotime("+9 hours"))."\t".$ipaddr."\t".$host."\t".$IndentType."\t".$DebugTag."\t".$_SERVER['HTTP_REFERER']."\n"; fputs($file,$string); flock($file,LOCK_UN); fclose($file); function gethostbyaddr_timeout1($ip){ $res=`nslookup -timeout=1 -retry=1 $ip`; if (preg_match('/name = (.*).\n/', $res, $out)){ return $out[1]; } else{ return $ip; } } if($before!=$msg){ $et = new ElapsTime(); $et->et_start(); $hf = new HtmlFormat(); $hf->hf_charSet($IndentType); $hf->DebugTag = $DebugTag; $after = $hf->hf_format($before); $before= htmlspecialchars($before,ENT_QUOTES); $after= htmlspecialchars($after,ENT_QUOTES); $et->et_end(); } class ElapsTime{ private $time; private $str; private $time_start; private $time_end; public function et_start(){ $this->time_start = $this->microtime_float(); } public function et_end(){ $this->time_end = $this->microtime_float(); $this->time = $this->time_end - $this->time_start; return $this->time; } public function et_print(){ $this->str = number_format($this->time,6,'.',','). "秒"; return $this->str; } private function microtime_float(){ list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } } class PatternConverte{ private $conv; public function pt_conv($input){ $pattern = '@'. '<!--.*?-->' .'|'. '<\?.*?\?>' .'|'. '<%.*?%>' .'|'. '<script[^>]*?>.*?</script>'.'|'. '<style[^>]*?>.*?</style>' .'|'. '<pre[^>]*?>.*?</pre>' . '@si'; $input = preg_replace_callback($pattern,array($this,'uniqConvert1'),$input); $pattern = '@'. '"[^<^>^"]*{[^<^>^"]+}[^<^>^"]*"'.'|'. "'[^<^>^']*{[^<^>^']+}[^<^>^']*'".'|'. '"[^<^>^"]*;[^<^>^"]*"' .'|'. "'[^<^>^']*;[^<^>^']*'" .'|'. "&[^&^;^<^>^ ]+;". '@si'; $input = preg_replace_callback($pattern,array($this,'uniqConvert2'),$input); return $input; } private function uniqConvert1($matches) { $id = md5(uniqid()); $val = $matches[0]; $key = '<'.$id.' />'; $this->conv[$key] = $val; return $key; } private function uniqConvert2($matches) { $id = md5(uniqid()); $val = $matches[0]; $key = '##'.$id.'##'; $this->conv[$key] = $val; return $key; } //復元&改行直後に$rcharを付加 public function pt_restore($input,$rchar){ if(is_null($rchar)){$rchar="";} if(!is_null($this->conv)){ foreach ($this->conv as $k => $v){ $after = str_replace($k,$v,$input); if($after<>$input){ $input = str_replace("\r\n","\r\n".$rchar,$after); } } } return $input; } //復活 public function pt_restore_org($input){ if(!is_null($this->conv)){ foreach ($this->conv as $k => $v){ $input = str_replace($k,$v,$input); } } return $input; } } class HtmlFormat{ public $beforeSize; public $afterSize; public $beforeCount; public $afterCount; public $indentChar; //インデントの文字 public $indentCount; //インデント文字の数 public $tagOkCount; public $tagNgCount; public $DebugTag; public $debugInfo; public $tagList; public function hf_charSet($num){ switch($num){ case '1': $this->indentChar="\t"; $this->indentCount=1; break; case '2': $this->indentChar=" "; $this->indentCount=1; break; case '3': $this->indentChar=" "; $this->indentCount=2; break; case '4': $this->indentChar=" "; $this->indentCount=4; break; default: $this->indentChar=" "; $this->indentCount=2; } } public function hf_cssFormat($input){ $input=str_replace("{","{\r\n",$input); $input=str_replace(";",";\r\n ",$input); $input=str_replace("}","\r\n}\r\n\r\n",$input); $input=str_replace("\r\n \r\n}\r\n\r\n ","\r\n}\r\n\r\n ",$input); $input=str_replace("\r\n}\r\n\r\n ","\r\n}\r\n\r\n",$input); return $input; } public function hf_format($str){ $this->beforeSize = strlen($str); $array=explode("\n",$str); $this->beforeCount=sizeof($array); $pc = new PatternConverte(); $str=$pc->pt_conv($str); //改行文字を取り除く $str=str_replace("\r\n","\r\n ",$str);// $str=str_replace("\r\n","",$str);// $str=str_replace("\n","",$str);// $str=trim($str); //タブ文字を取り除く $str=str_replace("\t","",$str); //連続した半角空白文字を1文字半角にする $str = preg_replace('/\s\s+/', ' ', $str); //タグの先頭に改行文字を設定する $str=str_replace("<","\n<",$str); $str=str_replace("\n<?","<?",$str); //タグの末尾直後の半角空白を削除 $str=str_replace("> ",">",$str); //変数から配列に変換する $array=explode("\n",$str); //htmlの属性を$list配列に転記する for($i=0;$i<count($array);$i++){ $list[$i]["html"]=$array[$i]; $html=$array[$i]; if(mb_substr($array[$i],0,2)=="</"){ $list[$i]["startend"]="end"; $list[$i]["tag"]=mb_substr(str_replace(" ",">",$html) , 2 , mb_strpos(str_replace(" ",">",$html),'>') - 2 ); $list[$i]["value"]=0; $list[$i]["level"]=0; $list[$i]["n_html"]=""; }elseif(mb_substr($array[$i],0,2)=="<!"){ $list[$i]["startend"]="coment"; $list[$i]["tag"]=""; $list[$i]["value"]=0; $list[$i]["level"]=0; $list[$i]["n_html"]=""; }elseif(mb_substr($array[$i],0,1)=="<"){ $list[$i]["startend"]="start"; $list[$i]["tag"]=mb_substr(str_replace(" ",">",$html) , 1 , mb_strpos(str_replace(" ",">",$html),'>') - 1 ); $list[$i]["value"]=0; $list[$i]["level"]=0; $list[$i]["n_html"]=""; }else{ $list[$i]["startend"]="coment"; $list[$i]["tag"]=mb_substr(str_replace(" ",">",$html) , 0 , mb_strpos(str_replace(" ",">",$html),'>')); $list[$i]["value"]=0; $list[$i]["level"]=0; $list[$i]["n_html"]=""; } } //タグ・startend別の使用回数をカウントする (タグ別集計) for($i=0;$i<count($list);$i++){ if($list[$i]["startend"]<>"coment"){ $sum[strtolower($list[$i]["tag"])][$list[$i]["startend"]] = $sum[strtolower($list[$i]["tag"])][$list[$i]["startend"]] + 1 ; } } if(count($sum)<>0){ //tag順にソートする ksort($sum); //タグ別集計にvalueを設定する //start/endのタグが正しくペアの状態になっている場合 ->1をセット //endタグを持たない場合、endタグが不完全(記入漏れ)の場合 ->0をセット // $i=0; while(list($key,$var)=each($sum)){ $start=0; $end=0; while(list($key2,$var2)=each($var)){ if($key2=="start"){$start=$var2;} if($key2=="end"){$end=$var2;} } $sum[$key]["sa"]=$end - $start; if($sum[$key]["sa"]==0){ $sum[$key]["value"]=1; $this->tagOkCount = $this->tagOkCount." ".$key.":(".$var[start].")"; } else{ $sum[$key]["value"]=0; if(strlen($key)>0 and strlen($key)<30){ $this->tagNgCount = $this->tagNgCount." ".$key.":(".$sum[$key]["sa"].")"; $this->tagList[$i]=$key;$i=$i+1; } } } } $this->tagOkCount = htmlspecialchars($this->tagOkCount,ENT_QUOTES); $this->tagNgCount = htmlspecialchars($this->tagNgCount,ENT_QUOTES); //$list配列にタグ別集計の値を反映する for($i=0;$i<count($list);$i++){ //valueをセット if($list[$i]["startend"]=="start"){ $list[$i]["value"]=$sum[strtolower($list[$i]["tag"])]["value"]; }elseif($list[$i]["startend"]=="end"){ $list[$i]["value"]=$sum[strtolower($list[$i]["tag"])]["value"]*-1; }else{ $list[$i]["value"]=0; } //levelをセット if($i==0){ $list[$i]["level"]=$list[$i]["value"]; }else{ $list[$i]["level"]=$list[$i-1]["level"]+$list[$i]["value"]; } } //valueの値が-1の場合に、levelの値に1を加算する for($i=0;$i<count($list);$i++){ if($list[$i]["value"]==-1){ $list[$i]["level"]=$list[$i]["level"]+1; } } //level補正(2012/12/20) for($i=1;$i<count($list);$i++){ //valueの値が0 & 前のvalueが0以外の場合に、levelの値に1を加算する //valueの値が0 & 前のvalueが0の場合に、前のlevelをコピーする if($list[$i]["value"]==0){ if($list[$i-1]["value"]==0){ $list[$i]["level"]=$list[$i-1]["level"]; }else{ $list[$i]["level"]=$list[$i]["level"]+1; } } } //整形htmlを作成 for($i=0;$i<count($list);$i++){ if($list[$i]["level"]!=1){ $temp=@str_repeat($this->indentChar,($list[$i]["level"]-1) * $this->indentCount) ; $list[$i]["n_html"]=$temp. $list[$i]["html"]; }else{ $list[$i]["n_html"]=$list[$i]["html"]; } } //echo "<pre>"; //print_r($list); //echo "</pre>"; //デバッグ情報を作成 $this->DebugTag $seq=0;$val=0; for($i=0;$i<count($list);$i++){ if(strtolower($list[$i]["tag"])==$this->DebugTag){ if(mb_strlen($list[$i]["n_html"])>120){ $str=htmlspecialchars(mb_substr($list[$i]["n_html"],1,120))."..."; }else{ $str=htmlspecialchars($list[$i]["n_html"]); } $seq=$seq+1; if($list[$i]["startend"]=="start"){ $val=$val+1; }else{ $val=$val-1; } $this->debugInfo = $this->debugInfo." " .$seq." " ." (" .$val.") " .$list[$i]["startend"]."Tag : " .$str ."<br>\n"; }else{ } } $this->debugInfo = $pc->pt_restore_org($this->debugInfo); //次のタグが同一終了タグの場合、1行にまとめる $after=""; for($i=0;$i<count($list);$i++){ if($list[$i]["value"]==1){ if($list[$i+1]["value"]==-1){ if($list[$i]["tag"]==$list[$i+1]["tag"]){ //改行文字を取り除く $str=str_replace("\r\n","",$list[$i]["n_html"]); $str=str_replace("\n","",$str); $list[$i]["n_html"]= $str; $str=str_replace("\r\n","",$list[$i+1]["n_html"]); $str=str_replace("\n","",$str); $str=trim($str); $list[$i+1]["n_html"]= $list[$i]["n_html"].$str; $i++; } } } $temp=@str_repeat($this->indentChar,($list[$i]["level"]-1) * $this->indentCount) ; //$after= $after.$pc->pt_restore($this->hf_cssFormat($list[$i]["n_html"]),$temp)."\n"; //$after= $after.$pc->pt_restore($list[$i]["n_html"],$temp)."\n"; $after= $after.$pc->pt_restore($list[$i]["n_html"],null)."\n"; } $after=substr($after,0,strlen($after)-1); $this->afterSize = strlen($after); $array=explode("\n",$after); $this->afterCount=sizeof($array); return $after; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="ja"> <head> <title>HTML整形ツール(プチ・デバッグ機能付き)</title> <meta http-equiv="content-type" content="text/html; charset=EUC-JP"> <meta http-equiv="X-UA-Compatible" content="IE=IE9" > <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/core.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/coreLTR.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/defaultTheme.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/defaultThemeLTR.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/xsp.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/xspLTR.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/xspIE78.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/csscustom.css"> <link rel="stylesheet" type="text/css" href="http://dp25299446.lolipop.jp/css/1UIclasses.css"> <link rel="shortcut icon" href="http://www.u670.com/wp-content/themes/1024px/favicon.ico"> <script src="src/ace.js" type="text/javascript" charset="utf-8"></script> <script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script> <script src="src/mode-html.js" type="text/javascript" charset="utf-8"></script> <script language="JavaScript"> <!-- var value; var xmlHttp; var buf; var file; var spchar; var count; //テキストの行数 loadText(); function loadText() { if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else { if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { xmlHttp = null; } } xmlHttp.onreadystatechange = checkStatus; xmlHttp.open("GET", "http://u670.com/pikamap/amazon2.txt", true); xmlHttp.send(null); } function checkStatus() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { buf = xmlHttp.responseText; spchar = "\n"; file = buf.split(spchar); count = file.length - 1; mmset(); } } function mmoutput() { target = document.getElementById("output"); var mmno = value + 1; target.innerHTML = file[value] + '<div class="amazlet-powered-date" style="font-size:80%;margin-top:5px;line-height:120%">' + mmno + "/" + count + "</div><br><br>"; } function mmset() { value = Math.floor(Math.random() * count); mmoutput(); } function mmtop() { value = 0; mmoutput(); } function mmdec() { value = value - 1; if (value == -1) { value = value + count; } mmoutput(); } function mmadd() { value = value + 1; if (value == count) { value = value - count; } mmoutput(); } function eraseTA(obj) { if (obj.value == "HTMLを貼り付けてください。"){ obj.value = ""; obj.style.backgroundColor = "#ffffdd";} } // --> </script> <script language="JavaScript"> <!-- var value2; var xmlHttp2; var buf2; var file2; var spchar2; var count2; //テキストの行数 loadText2(); function loadText2() { if (window.XMLHttpRequest) { xmlHttp2 = new XMLHttpRequest(); } else { if (window.ActiveXObject) { xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP"); } else { xmlHttp2 = null; } } xmlHttp2.onreadystatechange = checkStatus2; xmlHttp2.open("GET", "http://u670.com/pikamap/amazon3.txt", true); xmlHttp2.send(null); } function checkStatus2() { if (xmlHttp2.readyState == 4 && xmlHttp2.status == 200) { buf2 = xmlHttp2.responseText; spchar2="\n"; file2=buf2.split(spchar2); count2=file2.length - 1; } } function mmoutput2() { target = document.getElementById("toparea"); target.innerHTML = file2[value2]; } function mmset2() { value2 = Math.floor(Math.random() * count2); mmoutput2(); } // --> </script> <style type="text/css"> <!-- #editor { width:99%; height:640px; text-align:left; } .ace_scroller { left: 47px; right: 17px; overflow-x: hidden; } img { max-width:300px; max-height:400px; } --> </style> </head> <body class="xspView tundra" style="color:#4088b8"> <div class="lotusFrame" style="min-width:1000px; max-width:2000px"> <div class="lotusBanner"> <div class="lotusRightCorner"> <div class="lotusInner" style="margin-right:10px"> <a href="http://www.u670.com/" target="_blank"> <span class="lotusTextLabel" style="margin-left:10px"> <b> <font color="#ff00cc">Pika's Home </font> </b> </span> </a> <span class="str"> お勧めサイト></span> <a href="http://dhive.jp/blog/yama/9326.html" target="_blank" title="Smart Indenter"> <span class="lotusTextLabel" style="margin-left:10px">VBA整形</span> </a> <a href="http://www.vector.co.jp/soft/win95/prog/se423429.html" target="_blank" title="WPEditor"> <span class="lotusTextLabel" style="margin-left:10px">VBScript整形</span> </a> <a href="http://www.codebeautifier.com/" target="_blank" title="code beautifier"> <span class="lotusTextLabel" style="margin-left:10px">CSS整形</span> </a> <a href="http://beta.phpformatter.com/" target="_blank" title="php formatter"> <span class="lotusTextLabel" style="margin-left:10px">PHP整形</span> </a> <a href="http://jsbeautifier.org/" target="_blank" title="jsbeautifier"> <span class="lotusTextLabel" style="margin-left:10px">JavaScript整形</span> </a> <a href="http://www.rider-n.sakura.ne.jp/regexp/regexp.php" target="_blank" title="PHP正規表現チェッカー"> <span class="lotusTextLabel" style="margin-left:10px">正規表現チェッカー</span> </a> <a href="http://www.dpriver.com/pp/sqlformat.htm" target="_blank" title="Instant SQL Formatter"> <span class="lotusTextLabel" style="margin-left:10px">SQL整形</span> </a> <span class="lotusTextLabel" style="margin-left:10px">累計: <script type="text/javascript" src="http://accnt.dp25299446.lolipop.jp/cnt/accnt.php?cnt_id=1664983&ac_id=LA01628307&mode=total&type=text"></script> </span> <span class="lotusTextLabel" style="margin-left:10px">昨日: <script type="text/javascript" src="http://accnt.dp25299446.lolipop.jp/cnt/accnt.php?cnt_id=1664983&ac_id=LA01628307&mode=yesterday&type=text"></script> </span> <span class="lotusTextLabel" style="margin-left:10px">本日: <script type="text/javascript" src="http://accnt.dp25299446.lolipop.jp/cnt/accnt.php?cnt_id=1664983&ac_id=LA01628307&mode=today&type=text"></script> </span> </div> </div> </div> <div class="lotusTitleBar"> <div class="lotusRightCorner"> <div class="lotusInner"> <span class="customTitle"> <b> <a href="<?php echo"http://" . $_SERVER["SERVER_NAME"] . $_SERVER["SCRIPT_NAME"]?>" style="text-decoration:none;"> <font color="#ffffff">HTML整形ツール(プチ・デバッグ機能付き)</font> </a> </b> </span> </div> </div> </div> <div class="lotusPlaceBar" style="height:6em;"> <div class="lotusRightCorner"> <div class="lotusInner" style="margin:10px 10px 10px 10px"> <b>注意事項:</b>◆このツールは「<」「>」マークを元に、HTMLを見やすく整形してくれる単純なツールです。 ◆不完全なタグが見つかると、対象タグの一覧を表示するプチデバッグ機能を追加しました。 ◆一行の長さは8000バイト以内してください。制限を超えると応答が帰らない場合があります。 ◆当ツールへのご意見、ご要望は <a href="http://www.u670.com">"Pika's home"</a>へお願いします。 </div> </div> </div> <div class="lotusMain" style="background-image: none"> <div class="lotusContent"> <table width="100%" height="30" border="0"> <tr> <td valign="top"> <form action="<?php echo"http://" . $_SERVER["SERVER_NAME"] . $_SERVER["SCRIPT_NAME"]?>" method="post"> <table width="99%" align="center" border="0" cellspacing="0" cellpadding="0" style="margin: 0px 0pt 0pt 0px;"> <tr> <td bgcolor="#afafaf" > <table width="100%" border=0 cellspacing=1 cellpadding=5 style="font-size:12px;"> <tr style="background-color: #eeeeee;" align="center"> <td style="text-align:center"> <textarea name="before" wrap="off" style="width:96%;height:165px;font-size:1.1em;resize: none" onMousedown="eraseTA(this)"><?php echo $before; ?></textarea> </td> </tr> <tr style="background-color: #eeeeee"> <td bgcolor=#eeeeee style="text-align:center" > <input type=submit value="整 形" name=start> </td> </tr> <tr style="background-color: #eeeeee;" align="center"> <td style="text-align:center"> <div id="editor"><textarea name="after" wrap="off" style="width:96%; height:640px; font: 13px Helvetica, Arial, sans-serif"><?php echo $after; ?></textarea></div> </td> </tr> </table> </td> </tr> </table> <div style="padding: 0px 22px 10px 22px"> <br> <?php if($before!=$msg){ echo "<b>1)処理時間:</b>".$et->et_print(); echo "<b> 2)整形前:</b>".$hf->beforeSize."バイト、".$hf->beforeCount."行"; echo "<b> 3)整形後:</b>".$hf->afterSize ."バイト、".$hf->afterCount ."行<br>\n"; echo '<b>4)インデント対象外タグ(終了タグ不足数):</b><font color="#ff00cc">'.$hf->tagNgCount."</font><br>\n"; echo "<b>5)インデント対象タグ(開始タグ数):</b>".$hf->tagOkCount."<br><br>\n"; if($DebugTag<>""){ echo "<b>6)デバッグ情報:( )内の数値はstartTagで+1、endTagで-1します。不完全なタグを見つける際の参考にしてください。</b><br>\n"; echo $hf->debugInfo."<br>\n"; } }else{ echo "※整形すると処理情報、デバッグ情報が表示されます。";} ?> </div> </td> <td width="312" valign="top"> <!-- <a href="http://www.amazon.co.jp/exec/obidos/ASIN/4839943842/mkcdg025-22/ref=nosim/" name="amazletlink" target="_blank">◆これスゴイです!! キッパリ(^^)/<br>HTMLを触ってる人なら必見です!<br>久々にワクワクするツールに出会えました<br>concrete5の日本語での解説書はこれだけ<img src="http://ecx.images-amazon.com/images/I/61PTO1dKHGL.jpg" width="312" hight="250" alt="concrete5 公式活用ガイドブック (Web Designing BOOKS)" style="border: none;" /></a> --> <a href=http://udo.jp/Artists/Boston/index.html#tokyo><b>◆BOSTOMがやってくる!!!</b><br>残された最後の奇跡!天才トム・ショルツ率いる伝説のバンドが前回の来日から<b>35年</b>の時を超え、日本への幻想飛行! 次はもう無いかも... <br><br>・東京公演 10月2・9日 <br>・名古屋公演 10月4日 <br>・大阪公演 10月6日<br></a><a href="http://www.amazon.co.jp/exec/obidos/ASIN/B00FZH9OYG/mkcdg025-22/ref=nosim/" name="amazletlink" target="_blank"><img src="http://ecx.images-amazon.com/images/I/51u4JnrX1wL.jpg" alt="ライフ、ラヴ&ホープ" style="border: none;" /></a> <!-- <div id="toparea"><script language="JavaScript">mmset2();</script></div> --> <br><br> <input type="button" value=" < " onclick="mmdec();" /> <input type="button" value=" > " onclick="mmadd();" /> <div id="output"><script language="JavaScript">mmset();</script></div> </td> </tr> <div style="padding: 0px 0px 0px 3px">Indent Type <select name="IndentType"> <option value="3" <?php if($IndentType=="3"){echo "selected";}?>>Blank * 2 </option> <option value="1" <?php if($IndentType=="1"){echo "selected";}?>>Tab </option> <option value="2" <?php if($IndentType=="2"){echo "selected";}?>>Blank * 1 </option> <option value="4" <?php if($IndentType=="4"){echo "selected";}?>>Blank * 4 </option> </select> <?php if(count($hf->tagList)<>0){ echo '<font color="#ff00cc"> Debug Tag</font>'; echo ' <select name="DebugTag">',"\n"; echo ' <option value=""'; if ($DebugTag==""){echo " selected ";} echo ">"."</option>\n"; for($i=0;$i<count($hf->tagList);$i++){ echo ' <option value="'.$hf->tagList[$i].'"'; if ($DebugTag==$hf->tagList[$i]){echo " selected ";} echo ">".$hf->tagList[$i]."</option>\n"; } echo " </select>\n"; } ?> <span class="lotusTextLabel"> お知らせ等は <a href=http://www.u670.com/category/html/ target="_blank"> <b>こちら</b> </a>をご覧ください。 </span> </form> </div> </table> </div> </div> <div class="lotusLegal" style="text-align:center"> <span class="lotusTextLabel">2007 (c) ohishi All Rights Reserved | リンクは自由に張ってくださってOKです</span> </div> </div> <script> var editor = ace.edit("editor"); editor.getSession().setMode("ace/mode/html").Mode; editor.setHighlightActiveLine(false); </script> </body> </html> admin
twitter に送ったんですが、使っておられないようなので。 整形ツールの右サイドが ◆BOSTOMがやってくる!!! になっています。 それと、属性毎に改行して縦に並べるオプションは 無理でしょうか。 さらに、PHP の を要素として判断しないオ プションは無理でしょうか。 失礼しました。 返信
lightboxさん、コメントありがとうございます(^^)/ BOSTOM直しました。お恥ずかしい(>_<) リクエストを整理すると... 1)属性毎に改行して縦に並べる こんな感じですか? <link rel="stylesheet" href="../css/common.css" type="text/css" /> 2)PHPを整形対象にするオプション <? ?>で囲ってるところを整形対象から外してますが、これをオプションで整形対象に出来るようにするってことですか? 返信
1) そうです。C# の XAML で使われています。 属性毎に内容を見てもらう時に使っています。 2) <input type=”text” value=”<?= $abc ?>”> が <input type=”text” value=” <?= $abc ?>”> なってしまっています。 無意味に改行が入ってしまっていますので・・・ もしできたら嬉しいなぁ・・・ なんて思っています。 ちなみに、専門学校でプログラミング教えている ので、学生に説明する時に便利だと思っています。 返信
2)は改行が問題だったんですね。 ダブルクオーテーションで囲った部分の<はメタ文字に変換してしまうか、または、ダブルクオーテーションで囲った部分は整形対象から外すかで、対応しようかと思います。 メタ文字変換は、こんな感じになります 変換前 <input type="text" value="<?= $abc ?>"> 変換後 <input type="text" value="<?= $abc ?>" /> 返信
お返事ありがとうございます。 >ダブルクオーテーションで囲った部分は整形対象から外す こちらの都合ではこのオプションが助かります。 整形したまま、PHP のソースとして使える事が できるとうれしいので。 ただ、使う人によっては、HTML エンティティに変換した い場合もあるかもしれません。 あと、同程度の可能性として、 <![CDATA[ ]]> の間も、整形対象から外したほうが良いように思います。 返信
UIはそのままで、機能だけ組み込んでみました。 出来立てほやほやですが、お試しください。 http://u670.com/pikamap/htmlseikei2.php 追記: 属性を縦に並べるとこは、属性外の空白を含む文字列も改行しちゃってました。 なかなかむつかしいですね。 返信
いろいろご対応ありがとうございます。 さっそくですが・・・ <form name=”f1″ method=”post” action=”send.php” target=”_blank”> <input <?= $umekomi ?> type=”hidden” name=”time1″ id=”times1″> <input type=”hidden” name=”time2″ id=”times2″> </form> が <form name=”f1″ method=”post” action=”send.php” target=”_blank”> <input <?= $umekomi ?>type=”hidden” name=”time1″ id=”times1″> <input type=”hidden” name=”time2″ id=”times2″> </form> となります。 私はダブルクォートの中だけの事を言ってましたが このようなパターンを前もって言えなかった事を本 当に申し訳なく思っています。 PHPの埋め込みの場合、HTMLタグ内は整形対象から外す というのが本来お伝えすべき仕様でした。すみません。 ( こけだけでは無く、他の仕様もありえると思います ) それと、属性毎の改行に使う整形用のスペースが、 2文字のスペース固定です。私はこれでも十分使えて うれしいのですが、一般的には Indent Type を使う ほうがいいかもしれません。 ありがとうございました。 返信
ご対応ありがとうございます。 本当はもっとハメを外したいくらい感謝しております。 来週の授業でさっそく使う予定にしております。 学生が PHP で出力するメチャメチャなコードが 美しくもエレガントに変身する事でしょう。 ( それを再度 view コードとして使います ) それでは、失礼致します。 返信
>属性の改行は2個目からにしました。 確かに…。これで、HTML5 のDOCTYPE が改行せずにすみます。 C# のオプションにもあったのを忘れていました。 ちなみに、<% %> は、ASP のコード範囲です。 PHP でもオプションで使えた記憶があります。 正式リリースという事でこちらのサイトからリンクを 貼らせていただきます。 本当にありがとうございました。 返信
twitter に送ったんですが、使っておられないようなので。
整形ツールの右サイドが
◆BOSTOMがやってくる!!!
になっています。
それと、属性毎に改行して縦に並べるオプションは
無理でしょうか。
さらに、PHP の を要素として判断しないオ
プションは無理でしょうか。
失礼しました。
このコメント欄、タグ書くと消えちゃうんですね。
PHPタグを無視するオプションが欲しいです。
埋め込みした view ソースのまま整形したいです。
lightboxさん、コメントありがとうございます(^^)/
BOSTOM直しました。お恥ずかしい(>_<) リクエストを整理すると... 1)属性毎に改行して縦に並べる こんな感じですか? <link rel="stylesheet" href="../css/common.css" type="text/css" /> 2)PHPを整形対象にするオプション <? ?>で囲ってるところを整形対象から外してますが、これをオプションで整形対象に出来るようにするってことですか?
1) そうです。C# の XAML で使われています。
属性毎に内容を見てもらう時に使っています。
2)
<input type=”text” value=”<?= $abc ?>”>
が
<input type=”text” value=”
<?= $abc ?>”>
なってしまっています。
無意味に改行が入ってしまっていますので・・・
もしできたら嬉しいなぁ・・・
なんて思っています。
ちなみに、専門学校でプログラミング教えている
ので、学生に説明する時に便利だと思っています。
2)は改行が問題だったんですね。
ダブルクオーテーションで囲った部分の<はメタ文字に変換してしまうか、または、ダブルクオーテーションで囲った部分は整形対象から外すかで、対応しようかと思います。
メタ文字変換は、こんな感じになります
変換前
<input type="text" value="<?= $abc ?>">
変換後
<input type="text" value="<?= $abc ?>" />
お返事ありがとうございます。
>ダブルクオーテーションで囲った部分は整形対象から外す
こちらの都合ではこのオプションが助かります。
整形したまま、PHP のソースとして使える事が
できるとうれしいので。
ただ、使う人によっては、HTML エンティティに変換した
い場合もあるかもしれません。
あと、同程度の可能性として、
<![CDATA[
]]>
の間も、整形対象から外したほうが良いように思います。
UIはそのままで、機能だけ組み込んでみました。
出来立てほやほやですが、お試しください。
http://u670.com/pikamap/htmlseikei2.php
追記:
属性を縦に並べるとこは、属性外の空白を含む文字列も改行しちゃってました。
なかなかむつかしいですね。
いろいろご対応ありがとうございます。
さっそくですが・・・
<form name=”f1″ method=”post” action=”send.php” target=”_blank”>
<input <?= $umekomi ?> type=”hidden” name=”time1″ id=”times1″>
<input type=”hidden” name=”time2″ id=”times2″>
</form>
が
<form
name=”f1″
method=”post”
action=”send.php”
target=”_blank”>
<input
<?= $umekomi ?>type=”hidden”
name=”time1″
id=”times1″>
<input
type=”hidden”
name=”time2″
id=”times2″>
</form>
となります。
私はダブルクォートの中だけの事を言ってましたが
このようなパターンを前もって言えなかった事を本
当に申し訳なく思っています。
PHPの埋め込みの場合、HTMLタグ内は整形対象から外す
というのが本来お伝えすべき仕様でした。すみません。
( こけだけでは無く、他の仕様もありえると思います )
それと、属性毎の改行に使う整形用のスペースが、
2文字のスペース固定です。私はこれでも十分使えて
うれしいのですが、一般的には Indent Type を使う
ほうがいいかもしれません。
ありがとうございました。
ご対応ありがとうございます。
本当はもっとハメを外したいくらい感謝しております。
来週の授業でさっそく使う予定にしております。
学生が PHP で出力するメチャメチャなコードが
美しくもエレガントに変身する事でしょう。
( それを再度 view コードとして使います )
それでは、失礼致します。
属性の改行は2個目からにしました。
新版をリリースしましたので、お試しください。
>属性の改行は2個目からにしました。
確かに…。これで、HTML5 のDOCTYPE が改行せずにすみます。
C# のオプションにもあったのを忘れていました。
ちなみに、<% %> は、ASP のコード範囲です。
PHP でもオプションで使えた記憶があります。
正式リリースという事でこちらのサイトからリンクを
貼らせていただきます。
本当にありがとうございました。