Writing a syntax highlighter

后端 未结 7 927
故里飘歌
故里飘歌 2020-12-23 10:28

I was hoping to write my own syntax highlighter for a summer project I am thinking of working on but I am not sure how to write my own syntax highlighter.

I know tha

7条回答
  •  隐瞒了意图╮
    2020-12-23 10:36

    It might help if you explain what this syntax highlighter is for. If you are writing it in actionscript, is your idea to have a text box in a flash movie and highlight the syntax after a submit button is pushed? Or do you want to read the text from some webservice and then display the highlighted syntax? ...it's hard for me to help, because it is hard for me to imagine what you are doing

    However, a syntax highlighter reads in text, then compares the lines of codes to some regex's which help the syntax highlighter figure out what the words mean. For example, it might read the word "function" or "int" as reserved words, and replace them with the html text:

    function, 
    

    assuming you have the css and want reserved words in red,

    .reserved{
      color: #ff0000;
    }
    

    This is the basic concept and you may want to take ideas from geshi since you can view the source.

提交回复
热议问题