블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2794)
Unity3D (852)
Programming (478)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (11)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
1. download : http://code.google.com/p/syntaxhighlighter/

2. 설치 
 다운로드 받은 파일을 압축해제후 scripts, styles 폴더 안에 있는 파일들을 스킨-직접 올리기에서 모두 올린다.
 그런 후에 아래 내용을 스킨-html/css 에서 html 태그중 </body> 위에 아래 내용을 추가한다.
  1. <!-- Syntax Highlighter start -->  
  2. <link type="text/css" rel="stylesheet" href="./images/SyntaxHighlighter.css"></link>  
  3. <script language="javascript" src="./images/shCore.js"></script>  
  4. <script language="javascript" src="./images/shBrushCpp.js"></script>  
  5. <script language="javascript" src="./images/shBrushCSharp.js"></script>  
  6. <script language="javascript" src="./images/shBrushCss.js"></script>  
  7. <script language="javascript" src="./images/shBrushDelphi.js"></script>  
  8. <script language="javascript" src="./images/shBrushJava.js"></script>  
  9. <script language="javascript" src="./images/shBrushJScript.js"></script>  
  10. <script language="javascript" src="./images/shBrushPhp.js"></script>  
  11. <script language="javascript" src="./images/shBrushPython.js"></script>  
  12. <script language="javascript" src="./images/shBrushRuby.js"></script>  
  13. <script language="javascript" src="./images/shBrushSql.js"></script>  
  14. <script language="javascript" src="./images/shBrushVb.js"></script>  
  15. <script language="javascript" src="./images/shBrushXml.js"></script>  
  16. <script language="javascript">  
  17. dp.SyntaxHighlighter.ClipboardSwf = 'http://your_address/images/clipboard.swf';  
  18. dp.SyntaxHighlighter.HighlightAll('code');  
  19. </script>  
  20. <!-- Syntax Highlighter start -->  


3. 사용법

  1. tag중 pre와 textarea에 대한 : http://code.google.com/p/syntaxhighlighter/wiki/PreAndTextarea
  2. 사용법에 대한 : http://code.google.com/p/syntaxhighlighter/wiki/Usage
  3. 사용 가능한 언어 : http://code.google.com/p/syntaxhighlighter/wiki/Languages
  4. 설정 : http://code.google.com/p/syntaxhighlighter/wiki/Configuration



    출처 : 
    http://srand.tistory.com/8 



Usage

Placing the code

Place your code on the page and surround it with <pre> tag. Set name attribute to code and class attribute to one of the language aliases you wish to use.

<pre name="code" class="c-sharp">
... some code here ...
</pre>

NOTE: One important thing to watch out for is opening triangular bracket <. It must be replaced with an HTML equivalent of &lt; in all cases. Failure to do won't break the page, but might break the source code displayed.

An alternative to <pre> is to use <textarea> tag. There are no problems with < character in that case. The main problem is that it doesn't look as good as <pre> tag if for some reason JavaScript didn't work (in RSS feed for example).

<textarea name="code" class="c#" cols="60" rows="10">
... some code here ...
</textarea>

Extended configuration

There's a way to pass a few configuration options to the code block. It's done via colon separated arguments.

<pre name="code" class="html:collapse">
... some code here ...
</pre>

Making it work

Finally, to get the whole thing to render properly on the page, you have to add JavaScript to the page.

<link type="text/css" rel="stylesheet" href="css/SyntaxHighlighter.css"></link>
<script language="javascript" src="js/shCore.js"></script>
<script language="javascript" src="js/shBrushCSharp.js"></script>
<script language="javascript" src="js/shBrushXml.js"></script>
<script language="javascript">
dp
.SyntaxHighlighter.ClipboardSwf = '/flash/clipboard.swf';
dp
.SyntaxHighlighter.HighlightAll('code');
</script>

For optimal result, place this code at the very end of your page. Check HighlightAll for more details about the function.

반응형
Posted by blueasa
, |