[ํฐ์คํ ๋ฆฌ ๊พธ๋ฏธ๊ธฐ] ์ฝ๋๋ธ๋ก ๋์์ธ ๋ณ๊ฒฝ
์ค๋น ๊ณผ์
ํฐ์คํ ๋ฆฌ ๊ด๋ฆฌ์ > ๊พธ๋ฏธ๊ธฐ - ์คํจ ํธ์ง > html ํธ์ง
+ ๋ง์ฝ ์ด์ ์ ํ๋ฌ๊ทธ์ธ์์ '์ฝ๋ ๋ฌธ๋ฒ ๊ฐ์กฐ'๋ฅผ ์ ์ฉํ๋ค๋ฉด ํด์ ํ๊ธฐ
1. ํ ๋ง
1) ์๋ ์ฌ์ดํธ์์ ์ํ๋ ํ ๋ง ๊ณ ๋ฅด๊ธฐ
https://highlightjs.org/static/demo/
highlight.js demo
highlightjs.org
2) ํ ๋ง ์ด๋ฆ ๋ณ๊ฒฝํ๊ธฐ
(1) ๋๋ฌธ์๋ ์๋ฌธ์๋ก ๋ณ๊ฒฝ
(2) ๋์ด์ฐ๊ธฐ๋ -(ํ์ดํ)์ผ๋ก ๋ณ๊ฒฝ
ex) Github Dark → github-dark
ex) Base16 / Ashes → base16/ashes
3) html์ <head> </head> ์ฌ์ด์ ์ฝ๋ ์ถ๊ฐํ๊ธฐ
<!-- ์ฝ๋๋ธ๋ญ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ถ๊ฐ -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/github-dark.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
2. ํฐํธ
1) ์๋์ ์ฌ์ดํธ์์ ์ํ๋ ํฐํธ ๊ณ ๋ฅด๊ธฐ
Browse Fonts - Google Fonts
Making the web more beautiful, fast, and open through great typography
fonts.google.com
2) ํฐํธ ๋ณต์ฌํ๊ธฐ
3) html์ <head> </head> ์ฌ์ด์ ์ฝ๋ ์ถ๊ฐํ๊ธฐ
<!-- ์ฝ๋๋ธ๋ญ ํฐํธ -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR&display=swap" rel="stylesheet">
4) css์ ์ฝ๋ ์ถ๊ฐํ๊ธฐ
/* ์ฝ๋๋ธ๋ก ํฐํธ style */
pre > code {
font-family: 'ํฐํธ ์ด๋ฆ', monospace !important;
font-size: 15px;
}
- font-family: ํฐํธ ์ด๋ฆ
- font-size: ํฐํธ ์ฌ์ด์ฆ
- (๊ทธ ์ธ ํ์ํ๋ค๋ฉด ๋ค๋ฅธ ๋ธ๋ก๊ทธ์์...)
3. ๋ผ์ธ ๋๋ฒ
1) html์ <head> </head> ์ฌ์ด์ ์ฝ๋ ์ถ๊ฐํ๊ธฐ
<!-- Line Number ์ ์ฉ -->
<script src="//cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.7.0/highlightjs-line-numbers.min.js"></script>
<script>hljs.initLineNumbersOnLoad();</script>
2) css์ ๋งจ ์๋์ ์ฝ๋ ์ถ๊ฐํ๊ธฐ
/* Line Number CSS */
/* for block of numbers */
.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: #B5B5B5;
border-right: 1px solid #B5B5B5;
vertical-align: top;
width: 20px;
padding-left: 0px;
}
/* your custom style here */
.hljs-ln td.hljs-ln-code {
padding-left: 15px;
}
3) ๋ง์ฝ ์ ์ฉํ ์ฝ๋๊ฐ ์ด๋ ๊ฒ ๋ณด์ธ๋ค๋ฉด... css์ table์ ์์ ํ์
<์ฝ๋ ์์ ์ >
<์ฝ๋ ์์ ํ>
<์ฝ๋ ์์ ์ >
<์ฝ๋ ์์ ํ>
์ถ์ฒ