tistory syntax highlight

tistory에 code highlight 적용 하는 방법.


먼저 해당 사이트에서 syntaxhighlighter를 다운 받는다.

(http://alexgorbatchev.com/SyntaxHighlighter/)


혹은 현재 최신 버전을 다운로드 받는다.

syntaxhighlighter_3.0.83.zip


그리고 압축을 풀어서 scripts, styles 폴더를 모두 업로드 한다.

이후 몇가지 셋팅을 해줘야 하는데.


skin.html 파일에 업로드한 scripts의 파일들중 사용하려는 js파일과 기본 core파일을 로드해줘야한다.

<script type="text/javascript" src="./images/shCore.js"></script>
<script type="text/javascript" src="./images/shAutoloader.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/shBrushCss.js"></script>
<script type="text/javascript" src="./images/shBrushXml.js"></script>
<script type="text/javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
</script>

또한 코드 노출시 사용하고 싶은 스타일을 따로 적용할수 있는데 styles에 포함된 파일들중 하나를 선택해서 로드하면 된다.

<link type="text/css" href="./images/shCore.css" rel="stylesheet" />
<link type="text/css" href="./images/shThemeDefault.css" rel="stylesheet" />

'컴퓨터 팁' 카테고리의 다른 글

코드 하이라이팅 사용법  (0) 2008.10.28
Excel 최대 행,열 수  (0) 2007.12.06
리눅스 파일 리스트 뽑아 내는 명령어  (0) 2007.11.13

jQuery와 prototype의 충돌 해결방법

jQuery와 prototype을 함께 사용시 $의 소유권 문제로 충돌이 발생하게 된다.


이때, 충돌을 해결하면서 jQuery와 prototype을 함께 사용하기 위해선 jQuery쪽에서 충돌을 해소해 줘야 한다.


(function($) {

    $(function() {
        jQuery source;
    });

})(jQuery);

물론 $J = jQuery.noConflict();와 같이 $의 소유권을 포기하는 방법도 있긴하지만.

매번 $J라고 지정한 변수를 통해 소스코드를 작성해야하는 번거로움이 있기에 jQuery 소스를 위와 같이 한번 감싸주는것으로 해결이 가능하다.


간혹 $를 모두 jQuery로 바꾼다는 무식한 얘길 하는 사람들이 있는데, 이건 정말 정말 무식한 방법이다.

소스상의 모든 $를 조회하여 jQuery로 변경한다는게 손도 많이 갈뿐 아니라 그에 따른 버그가 생길수도 있다.

그럴 바엔 차라리 jQuery 사용을 포기해라...

'WebDevelop > jQuery' 카테고리의 다른 글

jQuery .attr() vs .prop()  (0) 2015.04.27
jQuery selector시 좋은 습관  (0) 2009.10.13
jQuery Colorcharge  (0) 2009.01.15

숭례문 복구 기념, 김정기 작가 드로잉쇼


출처: http://www.youtube.com/watch?feature=player_embedded&v=IAOiNykq4NM

Return top