1. syntaxhighlighter 다운받고 압축 푼다.
2. scripts, styles 폴더안의 파일들을 Tistory 관리 >> HTML/CSS 편집 >> 파일 업로드 >> 추가 버튼 눌러서
모두 업로드해준다.
3. Tistory 관리 >> HTML/CSS 편집에 다시 들어가 CTRL + F 로 </head>를 찾는다.
찾고나서 </head> 바로 위에 다음 태그를 삽입해준다.(복붙)
<
script
type
=
"text/javascript"
src
=
"./images/shCore.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shLegacy.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushBash.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushCpp.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushCSharp.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushCss.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushDelphi.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushDiff.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushGroovy.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushJava.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushJScript.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushPhp.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushPlain.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushPython.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushRuby.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushScala.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushSql.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushVb.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"./images/shBrushXml.js"
></
script
>
<
link
type
=
"text/css"
rel
=
"stylesheet"
href
=
"./images/shCore.css"
>
<
link
type
=
"text/css"
rel
=
"stylesheet"
href
=
"./images/shThemeDefault.css"
>
<
script
type
=
"text/javascript"
>
SyntaxHighlighter.all();
</
script
>
4.
범용성을 늘리기 위해 우리는 textarea 태그를 이용할 것이므로 추가 수정이 필요하다.다시 CTRL + F로 <body>를 찾아주자.
찾았다면 <body>를 다음과 같이 덮어씌운다(바꾼다).
<body Onload="dp.SyntaxHighlighter.HighlightAll('code');">
5. 원래 Syntax Highlighter 적용법에는 크게 두가지가 있다. <pre> 태그 이용법과 <textarea> 태그 이용법, 하지만 <pre>태그를 이용하게 되면 html태그 코드를 사용할 때 많이 많이 불편하게 되므로 <textarea>태그를 이용하자.
간단하다. 글 작성할 때 코드를 쓰게된다면 먼저, HTML에티터 타입으로 변경한다.
그리고 나서 다음과 같이 입력해준다.
1 2 3 | < textarea name = "code" class = "brush:원하는 언어;" > 에디터 모드에서 이 사이에 코드를 작성하면 된다. </ textarea > |
'원하는 언어' 부분엔 아래 표를 참고해서 매칭되는 Brush aliases를 사용하면된다.
Brush name | Brush aliases | File name |
as3, actionscript3 | shBrushAS3.js | |
bash, shell | shBrushBash.js | |
cf, coldfusion | shBrushColdFusion.js | |
c-sharp, csharp | shBrushCSharp.js | |
cpp, c | shBrushCpp.js | |
css | shBrushCss.js | |
delphi, pas, pascal | shBrushDelphi.js | |
diff, patch | shBrushDiff.js | |
erl, erlang | shBrushErlang.js | |
groovy | shBrushGroovy.js | |
js, jscript, javascript | shBrushJScript.js | |
java | shBrushJava.js | |
jfx, javafx | shBrushJavaFX.js | |
perl, pl | shBrushPerl.js | |
php | shBrushPhp.js | |
plain, text | shBrushPlain.js | |
ps, powershell | shBrushPowerShell.js | |
py, python | shBrushPython.js | |
rails, ror, ruby | shBrushRuby.js | |
scala | shBrushScala.js | |
sql | shBrushSql.js | |
vb, vbnet | shBrushVb.js | |
xml, xhtml, xslt, html, xhtml | shBrushXml.js |