Thursday, October 29, 2015

how to make syntax highlight with javascript

I recently made a source that text javascript convert to color highlited script with html tags

below code is what I did and output
I have to do refactoring it providing multilanguage and modules.

I did it this step

1. split rows
2. parsing comments.
3. parsing String values
4. parsing variables
5. line num


https://github.com/jjhangu/colorbeauti/blob/master/test.html

If you need more detail
reply~

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    /**
 * 주석은 언제 작업하나?? ㅡ.ㅡ;
 */
(function(){
    var MailResizer = function(){
    }
    MailResizer.prototype.data ={
        isMode : 0// 0 default, 1 cotent resized, 2 only image resized
        isVertical : 1,  // 0 false, 1 true,
        imageObjectList : [] //  isMode가 2인경우에만 사용
    };
    // 텍스트 테스트
    var text = "<span id='hoho'>" + '<span id="haha">' ;
    var arr = [];
    var json = {};
    // 이중 for문 테스트
    for(var i=0; i<arr.length; i++){
        // 로그 테스트
        console.log("haha");
        for(var i in json){
            if(i.key == null){
                return ;
            }else if(i.key == true){
            }else if(i.key == false){
            }  /**  1단 테스트 */
            /* 주주석 */else{
                console.log('주석 테스트');
            }
            /**
             이단 테스트 function hohoho 이거는 2단 주석 테스트 입니다 )()()
             */
        }
    }
    var hello = this.call(data);
    window.MailResizer = MailResizer;
})();

No comments:

Post a Comment