tistory syntaxhighlighter 설정

일반 2012. 7. 26. 12:51

참고 : 다른 분것 참조를 했는데 링크를 읽어버렸습니다. ㅡㅡ;


위에 링크를 참조해서 span 태그의 whitepace 문제 수정







<script type="text/javascript">
<!--
;jQuery.noConflict();  // 다른 라이브러리와 충돌을 방지한다.
;(function($) { $(document).ready(function() {
//////////////////////////////////////////////////////////////////////////////////////
    $("blockquote[class^=brush]").each( function() {  //blokquote를 사용한 태그
        var $this = $(this);

        // 복사 붙여넣기 했을때 탭처리
        $this.find("span[class*=Apple-tab-span]").replaceWith(function() {
            return $(this).text();
        });

        // 편집창에서 직접 수정했을때 탭 처리
        $this.find("p[style*=margin-left]").each(function() {
            var $elem = $(this);
            var style = $elem.attr("style");
            var result = /\s*?margin-left:\s(\w+?)em;\s*?/gi.exec(style);
            if ( result != null ) {
                result = result[1];
            }
            var spaceCount = parseInt(result) * 2;
            var spaceString = "";
            for (var i = 0; i < spaceCount; i++) {
                spaceString += "&nbsp;";
            }
            $elem.removeAttr("style");
            $elem.html(spaceString + $elem.html());
        });

        var temp = $this.html(); //  내용 복사
        temp = temp.replace(/\n/gi, "");
        temp = temp.replace(/<p><\/p>/gi, "");
        temp = temp.replace(/<p><br\s*\/?><\/p>/gi, "\n");    // 줄바꿈
        temp = temp.replace(/<P>(.*?)<\/P>/gi, "$1\n");       // 한줄끝
        temp = temp.replace(/<br\s*\/?>/gi, "\n");            // 줄바꿈

        temp = '<script type="syntaxhighlighter" class="' + $this.attr('class') + '"><![CDATA[' + temp + ']]><\/script>'
        $this.replaceWith(temp);
    });
  
    $("pre[class^=brush]").each( function() {  //pre를 사용한 태그
    var $this = $(this);
        var temp = $this.html(); //  내용 복사
        temp = temp.replace(/</g, "&lt;");
        $this.html = temp;
    });     

    /*  SyntaxHighlighter 사용부분  */
    SyntaxHighlighter.defaults['toolbar'] = false; // 툴바 안 보기
    SyntaxHighlighter.all();
//////////////////////////////////////////////////////////////////////////////////////
});})(jQuery);
//-->
</script>


posted by 뚱2
posted by 뚱2
오브젝트브 C에 대한 .js 파일이 없기에 기존 shBrushCpp.js 파일을 이용해서 shBrushObjc.js 파일을 만들었습니다.

크게 바뀐건 없고 간단한 파일 @ 키워드와 [] 대괄호 부분을 하이라이트 했습니다.

알리아스 명은 objc, Objc 두개 사용가능 합니다.

제가 잘 사용하고 있는 기존 2.0.296 버전을 수정했습니다.

키워드 중 'CA\\w+ CF\\w+ NS\\w+ UI\\w+' 은 인터넷이서 찾다가 다른분걸 배꼈는데 어디서 찾았는지

기억이 나지않네요.

찾는데로 출처를 적겠습니다.




syntaxhighlighter_2.0.296_20110801.zip


 
posted by 뚱2
여러 버전 사용해 보고 나에게 제일 맞는 버전이라 생각이 든다.

내 블로그 적용한 이미지


 
posted by 뚱2