๊ทธ๋๋ณด๋ highlight.js ์ ์ฉ ๋ฐฉ๋ฒ
ํ์ด์ง ์ ๋ณด
๋ณธ๋ฌธ
https://gnu.kilho.net/tiptech/1210
ย
๊ทธ๋๋ณด๋ 5.4 ํ ์ด์ฉ
extend ํด๋์ highlight.php๋ก ์๋์ ๋ด์ฉ ์ ๋ ฅ
ย
![]()
ย
<?
ย function kh_tail_sub()
ย {
ย ย global $wr_id;
ย ย // ๊ฒ์ํ์์ view.php ํธ์ถํ ๋ ์ ์ฉํ๋๋ก
ย ย if($_SERVER['SCRIPT_NAME'] != '/bbs/board.php' ย || !$wr_id) return;
ย ?>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/a11y-dark.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
<script>
function sh(id) {
ย var $id = $("#" + id);
ย if ($id.length > 0) {
ย ย var html = $id.html();
// [ code]์ [ /code]์ ๊ณต๋ฐฑ์ ์ญ์
ย ย html = html.split("[ code]").join("<pre><code>");
ย ย html = html.split("[ /code]").join("</pre></code>");
ย ย $id.html(html);
ย ย $id.find("pre>code").each(function() {
ย ย ย var text = $.trim($(this).text());
ย ย ย $(this).text(text);
ย ย });
ย }
}
$(function() {ย
ย sh("bo_v_con");ย
ย hljs.initHighlighting();
});
</script>
ย <?
ย }
ย add_event('tail_sub', 'kh_tail_sub', G5_HOOK_DEFAULT_PRIORITY);
?>
๋๊ธ๋ชฉ๋ก
๋ฑ๋ก๋ ๋๊ธ์ด ์์ต๋๋ค.
