알짜게시판

[그누보드] Syntax Highlight 적용하기

그누보드 5.4 의 훅을 이용하였습니다. 따라서 5.4 미만의 버전에서는 지원하지 않습니다.

extend 폴더에 아무이름.php 로 아래의 내용을 입력하시면 됩니다.

글 작성시[ code] 와 [ /code] 사이의 텍스트에 적용됩니다.

[code]
 function kh_tail_sub()
{
 global $wr_id;

 // 게시판에서 view.php 호출할때 적용하도록
 if($_SERVER['SCRIPT_NAME'] != '/bbs/board.php' || !$wr_id) return;
?>
<link rel="stylesheet"
href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/styles/a11y-dark.min.css">
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script>

<script>
function sh(id) {
var $id = $("#" + id);
if ($id.length > 0) {
 var html = $id.html();
 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.configure({ tabReplace: '  ' });
hljs.initHighlighting();
});
</script>
<?
}
add_event('tail_sub', 'kh_tail_sub', G5_HOOK_DEFAULT_PRIORITY);
[/code]

* 참고
- https://highlightjs.org/
- https://sir.kr/g5_tip/4897

번호 제목 글쓴이 조회 날짜
223 [시크릿DNS] 프록시 혼합 사용 예제 1 249,215 08-07
222 [아이폰] HTTPS 감청 우회하기 101,203 11-01
221 [칼무리] 영역화면 크기 오류인 경우 94,443 12-12
220 [그누보드] CKEditor 5 플러그인 91,024 08-11
219 [그누보드] 사이드바 만들기 90,395 05-04
218 [MySQL] 업데이트 이후 에러 발생([ERROR] Incorrect definition of table … 90,375 12-08
217 [시크릿DNS] Kaspersky 백신 사용시 DNS 암호화 관련 4 83,256 01-04
216 [MySQL] MySQL, MariaDB 업데이트 72,765 11-24
215 ChangeDNS - DNS 서버를 손쉽게 변경합니다. 71,311 08-13
214 구글 크롬 탭검색 비활성화 71,020 12-04
213 [ReactNative] android directory was detected in the project. 64,674 07-20
212 killer 네트워크 이슈 팁 1 64,163 12-04
211 HTTPS/DNS 차단 쉽게 이해하기 61,529 08-16
열람 [그누보드] Syntax Highlight 적용하기 60,566 05-19
209 [윈도우] 윈도우11 시작 메뉴 위치 변경(가운데, 왼쪽) 59,895 10-10
208 [Delphi] 중복 실행 방지 58,395 09-21
207 [리눅스] yum 에서 Thread died in Berkeley DB library 오류 58,103 09-18
206 [리눅스] 메일(Mail) 삭제/초기화 57,396 07-18
205 [리눅스] 로그 삭제 및 비우기(?) 56,852 09-09
204 [윈도우] node.js 와 npm 업데이트(업그레이드) 56,747 12-01
203 [그누보드] 아이디 대신 이메일로 회원 가입하기 56,727 02-02
202 Windows에 Rust 설치하기 56,515 10-05
201 [그누보드] 훅을 통한 글쓰기, 댓글 알림 56,241 05-26
200 [리눅스] VNSTAT 설치하기 55,498 09-17
199 [ReactNative] 캐시 초기화 하는 방법 55,445 12-27
198 [Delphi] 윈도우 알림센터에 메시지 출력하기 54,535 06-20
197 [MySQL] unblock with 'mysqladmin flush-hosts' 에러 53,003 01-01
196 [Delphi] 파일 포맷 알아내기 50,850 09-08
195 [FTP] 500 Illegal PORT command. 46,695 09-03
194 [그누보드] 웹폰트 적용하기 45,484 08-13
193 [PHP] Imagek 를 이용한 썸네일 생성 45,306 08-26