E D R , A S I H C RSS

위키에 코드컬러라이저 추가하기

Code Colorizer

:
MoinMoin 1.0 부 Process 기반다. 그래 가능다.


MoinMoin 러라는 기본로 들다. 그러나 바나 C++ 러라는 기본 다. 그래 MoinMoin:ParserMarket C++ 다. 그런데 드블럭문 되는것다.
{{{~cpp 
{{{~cpp 
!#java
...
}}}
그런데 MoinMoin:ParserMarket  [http://bbs.rhaon.co.kr/mywiki/moin.cgi/ProgrammingTips_2fCStringFormat Example]라 된 곳 는것다...[[BR]]
 떻게 렇게   , 렇게 가! --;;(단 능력 부 가능다..)[[BR]]
그리 그 방법  결과가 다..;;

== 물 ==
 * . 다 3개   MoinMoin/parser 디렉 다.
  * [http://twistedmatrix.com/users/jh.twistd/moin/moin.cgi/parser_2fbase_2epy parser/base.py] [http://twistedmatrix.com/users/jh.twistd/moin/moin.cgi/parser_2fcplusplus_2epy parser/cplusplus.py] [http://twistedmatrix.com/users/jh.twistd/moin/moin.cgi/parser_2fjava_2epy parser/java.py]

 * 다 2개  MoinMoin/processor 디렉 다. (본    Colorize.py  PythonColorize.py 로  바꾸다.)
  * CppColorize.py
  {{{~cpp 
"""
    MoinMoin - Processor for Syntax Highlighting

    Copyright (c) 2002 by J?gen Hermann <jh@web.de>
    All rights reserved, see COPYING for details.

    $Id: Colorize.py,v 1.3 2002/04/17 19:24:58 jhermann Exp $
"""

import string, sys, cStringIO
from MoinMoin.parser import cplusplus

def process(request, formatter, lines):
    if not formatter.in_pre:
        sys.stdout.write(formatter.preformatted(1))

    if string.strip(lines[0]) == "#!cplusplus":
        del lines[0]

    buff = cStringIO.StringIO()
    colorizer = cplusplus.Parser(string.join(lines, '\n'), request, out = buff)
    colorizer.format(formatter, {})

    sys.stdout.write(formatter.rawHTML(buff.getvalue()))
    sys.stdout.write(formatter.preformatted(0))


  }}}
  * JavaColorize.py
  {{{~cpp 
"""
    MoinMoin - Processor for Syntax Highlighting

    Copyright (c) 2002 by J?gen Hermann <jh@web.de>
    All rights reserved, see COPYING for details.

    $Id: Colorize.py,v 1.3 2002/04/17 19:24:58 jhermann Exp $
"""

import string, sys, cStringIO
from MoinMoin.parser import java

def process(request, formatter, lines):
    if not formatter.in_pre:
        sys.stdout.write(formatter.preformatted(1))

    if string.strip(lines[0]) == "#!java":
        del lines[0]

    buff = cStringIO.StringIO()
    colorizer = java.Parser(string.join(lines, '\n'), request, out = buff)
    colorizer.format(formatter, {})

    sys.stdout.write(formatter.rawHTML(buff.getvalue()))
    sys.stdout.write(formatter.preformatted(0))


  }}}

==  ==
 MoinMoin/parser  는 wiki.py 를 .[[BR]]
다과 같 ...
{{{~cpp 
            if self.in_pre:
                if self.in_pre == 2:
                    # processing mode
                    endpos = string.find(line, "}} }") #  래는 
                    if endpos == -1:
                        self.colorize_lines.append(line)
                        continue

                    self.processor(self.request, self.formatter, self.colorize_lines)
                    del self.colorize_lines
                    self.in_pre = 0

                    # send rest of line through regex machinery
                    line = line[endpos+3:]                    
                elif string.strip(line)[:2] == "#!" and string.find(line, 'python') > 0:
                    from MoinMoin.processor.Colorize import process
                    self.processor = process
                    self.in_pre = 2
                    self.colorize_lines = [line]
                    continue
}}}
렇게 바꾸!
{{{~cpp 
            if self.in_pre:
                if self.in_pre == 2:
                    # processing mode
                    endpos = string.find(line, "}} }") #  래는 
                    if endpos == -1:
                        self.colorize_lines.append(line)
                        continue

                    self.processor(self.request, self.formatter, self.colorize_lines)
                    del self.colorize_lines
                    self.in_pre = 0

                    # send rest of line through regex machinery
                    line = line[endpos+3:]
                elif string.strip(line)[:2] == "#!" and string.find(line, 'cplusplus') > 0:
                    from MoinMoin.processor.CppColorize import process
                    self.processor = process
                    self.in_pre = 2
                    self.colorize_lines = [line]
                    continue
                elif string.strip(line)[:2] == "#!" and string.find(line, 'java') > 0:
                    from MoinMoin.processor.JavaColorize import process
                    self.processor = process
                    self.in_pre = 2
                    self.colorize_lines = [line]
                    continue
                elif string.strip(line)[:2] == "#!" and string.find(line, 'python') > 0:
                    from MoinMoin.processor.PythonColorize import process
                    self.processor = process
                    self.in_pre = 2
                    self.colorize_lines = [line]
                    continue
}}}
----
["류"], ["lostship"]
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:28
Processing time 0.0092 sec