์ž์œ ๊ฒŒ์‹œํŒ

  • ๊ทธ๋ˆ„๋ณด๋“œ highlight.js ์ ์šฉ ๋ฐฉ๋ฒ•

    ํŽ˜์ด์ง€ ์ •๋ณด

    profile_image
    ์ž‘์„ฑ์ž์ฒœ์‚ฌ ์กฐํšŒ 9,496ํšŒ ์ž‘์„ฑ์ผ 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);
    ?>

    ๋Œ“๊ธ€๋ชฉ๋ก

    ๋“ฑ๋ก๋œ ๋Œ“๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.