예제 #1
0
def parse_text(parser, text):
    """Parse the text for wiki text markup and valid text content and return a
    list of content object"""
    i = 0
    contents = []
    spchars = ''
    while i < len(text):
        ch2 = text[i:i + 2]
        ch3 = text[i:i + 3]
        if ch3 in ref3markups:
            if spchars:
                spchars_e = escape_htmlchars(spchars)
                contents.append(
                    Content(parser, spchars, TEXT_SPECIALCHAR, spchars_e))
                spchars = ''
            contents.append(Content(parser, ch3, markup2type[ch3]))
            i += 3
        elif ch2 in ref2markups:
            if spchars:
                spchars_e = escape_htmlchars(spchars)
                contents.append(
                    Content(parser, spchars, TEXT_SPECIALCHAR, spchars_e))
                spchars = ''
            contents.append(Content(parser, ch2, markup2type[ch2]))
            i += 2
        else:
            spchars = spchars + text[i]
            i += 1

    if spchars:
        spchars_e = escape_htmlchars(spchars)
        contents.append(Content(parser, spchars, TEXT_SPECIALCHAR, spchars_e))

    return contents
예제 #2
0
파일: zwast.py 프로젝트: prataprc/eazytext
def parse_text( parser, text ) :
    """Parse the text for wiki text markup and valid text content and return a
    list of content object"""
    i = 0
    contents = []
    spchars  = ''
    while i < len(text) :
        ch2 = text[i:i+2]
        ch3 = text[i:i+3]
        if ch3 in ref3markups :
            if spchars :
                spchars_e = escape_htmlchars( spchars )
                contents.append( Content( parser, spchars,
                                          TEXT_SPECIALCHAR, spchars_e ))
                spchars = ''
            contents.append( Content( parser, ch3, markup2type[ch3] ))
            i += 3
        elif ch2 in ref2markups :
            if spchars :
                spchars_e = escape_htmlchars( spchars )
                contents.append( Content( parser, spchars,
                                          TEXT_SPECIALCHAR, spchars_e ))
                spchars = ''
            contents.append( Content( parser, ch2, markup2type[ch2] ))
            i += 2
        else :
            spchars = spchars + text[i]
            i += 1

    if spchars :
        spchars_e = escape_htmlchars( spchars )
        contents.append( Content( parser, spchars, TEXT_SPECIALCHAR, spchars_e))

    return contents
예제 #3
0
 def __init__(self, parser, link):
     self.parser = parser
     # parse the text
     text = ''
     tup = link[2:-2].split('|', 1)
     if len(tup) == 2:
         text = escape_htmlchars(tup[1])
     # parse the href and for special notations
     href = tup[0].strip(' \t')
     if href and href[0] == '*':  # Open in new window
         html = '<a target="_blank" href="' + href[1:] + '">' + \
                text.strip(' \t') + '</a>'
     elif href and href[0] == '$':  # Anchor
         html = '<a name="' + href[1:] + '">' + text.strip(' \t') + '</a>'
     else:
         text = text or tup[0]
         html = '<a href="' + href + '">' + text.strip(' \t') + '</a>'
     self.contents = [Content(parser, link, TEXT_LINK, html)]
예제 #4
0
파일: zwast.py 프로젝트: prataprc/eazytext
 def __init__( self, parser, link ) :
     self.parser = parser
     # parse the text
     text = ''
     tup  = link[2:-2].split( '|', 1 )
     if len(tup) == 2 :
         text = escape_htmlchars( tup[1] )
     # parse the href and for special notations
     href = tup[0].strip(' \t')
     if href and href[0] == '*' :     # Open in new window
         html = '<a target="_blank" href="' + href[1:] + '">' + \
                text.strip(' \t') + '</a>'
     elif href and href[0] == '$' :   # Anchor
         html = '<a name="' + href[1:] + '">' + text.strip(' \t') + '</a>'
     else :
         text = text or tup[0]
         html = '<a href="' + href + '">' + text.strip(' \t') + '</a>'
     self.contents = [ Content( parser, link, TEXT_LINK, html ) ]
예제 #5
0
 def __init__(self, parser, fulltext, newline):
     self.parser = parser
     self.fulltext = fulltext
     self.fulltext_e = escape_htmlchars(fulltext)
     self.newline = Newline(parser, newline)
예제 #6
0
파일: zwast.py 프로젝트: prataprc/eazytext
 def __init__( self, parser, fulltext, newline ) :
     self.parser     = parser
     self.fulltext   = fulltext
     self.fulltext_e = escape_htmlchars( fulltext )
     self.newline    = Newline( parser, newline )