내용변환(conv_content -> html_purifier)시 hook을 사용해서 prismjs를 적용
[참고] https://prismjs.com/index.html#examples
1. 그누보드 extend폴더 안에 아래 파일 생성
prism.extend.php
[code]
add_event('tail_sub', 'prism_tail_sub', G5_HOOK_DEFAULT_PRIORITY);
add_replace('html_purifier_result', 'prism_html_purifier_result', 10, 3);
function prism_script(){
add_stylesheet('<link rel="stylesheet" href="'.G5_PLUGIN_URL.'/prism/prism.css">', -2);
$sh = '<script src="'.G5_PLUGIN_URL.'/prism/prism.js"></script>'.PHP_EOL;
$sh .= '<script>var is_SyntaxHighlighter = true;</script>';
add_javascript($sh, 0);
}
function prism_tail_sub(){
global $wr_id;
if($_SERVER['SCRIPT_NAME'] != '/bbs/board.php' || !$wr_id) return;
prism_script();
}
function PrismJS($m) {
$str = isset($m[3]) ? $m[3] : '';
if(!$str)
return;
$str = stripslashes($str);
$str = preg_replace("/(<br>|<br \/>|<br\/>|<p>)/i", "\n", $str);
$str = preg_replace("/(<div>|<\/div>|<\/p>)/i", "", $str);
$str = str_replace(" ", " ", $str);
$str = str_replace("/</", "<", $str);
$str = str_replace("/[/", "[", $str);
$str = str_replace("/{/", "{", $str);
if(!$str)
return;
$brush = isset($m[2]) ? strtolower(trim($m[2])) : 'html';
//prism_script();
return '<div class="line-numbers"><pre><code class="language-'.$brush.'">'.$str.'</code></pre></div>'.PHP_EOL;
}
function prism_html_purifier_result($str){
$content = preg_replace_callback("/(\[code\]|\[code=(.*)\])(.*)\[\/code\]/iUs", "PrismJS", $str); // PrismJS
return $content;
}
[/code]
2. https://prismjs.com/download.html 접속해서 테마, 언어, 기능 다운로드(prism.js, prism.css)

3. 다운로드한 파일(prism.js, prism.css)을 플러그인 폴더에 업로드

4. Prism 의 Okaidia 테마적용

게시글 목록
| 번호 | 제목 |
|---|---|
| 24318 | |
| 24317 | |
| 24315 | |
| 24309 | |
| 24294 | |
| 24293 | |
| 24277 | |
| 24262 | |
| 24260 | |
| 24253 | |
| 24251 | |
| 24236 | |
| 24233 | |
| 24228 | |
| 24226 | |
| 24221 | |
| 24214 | |
| 24203 | |
| 24201 | |
| 24199 | |
| 24196 | |
| 24195 | |
| 24194 | |
| 24192 | |
| 24191 | |
| 24187 | |
| 24185 | |
| 24183 | |
| 24172 | |
| 24168 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기