본문 바로가기
Tistory Web Coding

highlight 추가하기

by eclipse7727 2020. 4. 10.

코드를 쓸 때 이쁘게 쓰려면 highlight 를 추가하면 된다.

 

1. 먼저 아래 주소로 들어가서 맘에드는 디자인을 선택한다.

 

highlight.js demo

 

highlightjs.org

2. 아래 주소로 들어가 사용법 대로 코드를 적용한다.

 

How to use highlight.js

Getting Started The bare minimum for using highlight.js on a web page is linking to the library along with one of the styles and calling initHighlightingOnLoad: hljs.initHighlightingOnLoad(); This will find and highlight code inside of tags; it tries to de

highlightjs.org

 

아래는 Androidstudio 디자인을 적용한 것이다. 

<link rel="stylesheet" href="/path/to/styles/default.min.css"> default를 원하는 디자인 명으로 바꿔주면 됨.

<link rel="stylesheet" href="/path/to/styles/androidstudio.min.css">

<script src="/path/to/highlight.pack.js"></script>

<script>hljs.initHighlightingOnLoad();</script>

 

3. 만약 적용이 되지 않는다면 

 

<pre><code class="javascript">...</code></pre>

 

위의 코드를 통해 수동으로 적용이 가능하다.

 

 

 

 

 

 

 

반응형

'Tistory Web Coding' 카테고리의 다른 글

Date()  (0) 2020.01.24

댓글