자유게시판

그누보드 highlight.js 적용 방법

페이지 정보

profile_image
작성자천사 조회 12,467회 작성일 2021-07-28 16:06:24 댓글 0

본문

https://highlightjs.org/

https://gnu.kilho.net/tiptech/1210

 

그누보드 5.4 훅 이용

extend 폴더에 highlight.php로 아래의 내용 입력

 

3529376057_1627455318.8042.png

 

<?
  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);
?>

댓글목록

등록된 댓글이 없습니다.

Copyright © Claw’s Lab · blog.batifa.com