Notice
Recent Posts
Recent Comments
Tags
- NewYork Times 읽기
- matplotlib 객제 지향 방식
- fig ax 사용
- 티스토리 자동 목차
- 티스토리 목차
- TOC
- jupyter notebook shell commands
- tistory 목차
- tistory toc
- magic command
05-04 16:43
Archives
develop myself
tistory 코드 블록 line number 적용 본문
1 js 파일 다운로드
https://github.com/wcoder/highlightjs-line-numbers.js/blob/master/src/highlightjs-line-numbers.js
js 파일을 오픈소스로 공유해주는 개발자가 있다.highlightjs-line-numbers.js
파일을 다운로드한다.
위의 링크로 들어가 raw
로 소스코드를 날것의 상태로 한 후,
우클릭
=> 다른 이름으로 저장
을 통해 파일을 다운로드할 수 있다.
2 업로드
블로그 관리
> 스킨 편집
> html 편집
> 파일 업로드
에 위에서 다운로드한 파일을 업로드한다.
3 html > head 추가
<!-- line number -->
<script src="./images/highlightjs-line-numbers.js"></script>
<script> hljs.initLineNumbersOnLoad();
$(document).ready(function() {
$('code.hljs').each(function(i, block) {
hljs.lineNumbersBlock(block);
});
});
</script>
4 CSS 추가
/* line numbers */
.hljs-ln td.hljs-ln-numbers {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
text-align: center;
color: #ccc;
border-right: 1px solid #CCC;
vertical-align: top;
padding-right: 5px;
/* your custom style here */
}
/* for block of code */
.hljs-ln td.hljs-ln-code {
padding-left: 10px;
}
'Tips > blog' 카테고리의 다른 글
tistory 메뉴 사이드바 수정(반응형 #2 스킨) (0) | 2023.01.11 |
---|---|
tistory에 highlight.js, line number 적용시 문제 해결(반응형 #2 스킨) (0) | 2023.01.11 |
tistory code highlight 추가 (0) | 2023.01.10 |
tistory 블로그 toc 적용(반응형 #2 스킨) (0) | 2023.01.10 |
tistory 블로그 toc 적용(book club 스킨) (0) | 2023.01.10 |
Comments