Created
August 21, 2014 22:26
-
-
Save blrun/df70f12764cd9666be23 to your computer and use it in GitHub Desktop.
신택스 하이라이트 처리 루틴...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// 신택스하이라이트 처리 시작 | |
$codePattern = "#(\[[a-z]+\_code\:[0-9]+\{[^}]*?\}\]|\[\/[a-z]+\_code\])#si"; | |
$temp = preg_split($codePattern,$memo,-1,PREG_SPLIT_DELIM_CAPTURE); | |
for($i=0;$i<count($temp);$i++) { | |
for($j=0;$j<count($code);$j++) { | |
$pattern1 = "#\[".$code[$j]."\_code\:([0-9]+)\{([^}]*?)\}\]#i"; | |
$pattern2 = "#\[\/".$code[$j]."\_code\]#i"; | |
if(preg_match($pattern1,$temp[$i])) { | |
if($code[$j]=="php") | |
$temp[$i]=preg_replace($pattern1,"<pre class=\"brush: $code[$j]; html_script: true; first-line: \\1\" title=\"\\2\">",$temp[$i]); | |
else | |
$temp[$i]=preg_replace($pattern1,"<pre class=\"brush: $code[$j]; first-line: \\1\" title=\"\\2\">",$temp[$i]); | |
$temp[$i+1]=str_replace("&","&amp;",$temp[$i+1]); | |
$temp[$i+1]=str_replace("'","&#039;",$temp[$i+1]); | |
$temp[$i+1]=str_replace(""","&quot;",$temp[$i+1]); | |
$temp[$i+1]=str_replace(" ","&nbsp;",$temp[$i+1]); | |
$temp[$i+1]=str_replace("<","<",$temp[$i+1]); | |
$i+=1; | |
} | |
elseif(preg_match($pattern2,$temp[$i])) { | |
$temp[$i]="</pre>"; | |
} | |
} | |
} | |
$memo=""; | |
for($i=0;$i<count($temp);$i++) { | |
$memo = $memo.$temp[$i]; | |
} | |
// 신택스하이라이트 처리 끝 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment