Exemplo n.º 1
0
class WikiColorizer(object):
    def __init__(self, editor, colorizeSyntax, enableSpellChecking, runEvent):
        self._editor = editor
        self._helper = TextEditorHelper()
        self._enableSpellChecking = enableSpellChecking
        self._runEvent = runEvent

        self.text = TextFactory.make(None)
        self.bold = FontsFactory.makeBold(None).setParseAction(
            lambda s, l, t: None)
        self.italic = FontsFactory.makeItalic(None).setParseAction(
            lambda s, l, t: None)
        self.bold_italic = FontsFactory.makeBoldItalic(None).setParseAction(
            lambda s, l, t: None)
        self.underline = FontsFactory.makeUnderline(None).setParseAction(
            lambda s, l, t: None)
        self.heading = HeadingFactory.make(None).setParseAction(
            lambda s, l, t: None)
        self.command = CommandFactory.make(None).setParseAction(
            lambda s, l, t: None)
        self.link = LinkFactory.make(None).setParseAction(lambda s, l, t: None)
        self.url = UrlFactory.make(None).setParseAction(lambda s, l, t: None)
        self.linebreak = LineBreakFactory.make(None).setParseAction(
            lambda s, l, t: None)
        self.noformat = NoFormatFactory.make(None).setParseAction(
            lambda s, l, t: None)
        self.preformat = PreFormatFactory.make(None).setParseAction(
            lambda s, l, t: None)

        if colorizeSyntax:
            self.colorParser = (self.url | self.text | self.linebreak
                                | self.link | self.noformat | self.preformat
                                | self.command | self.bold_italic | self.bold
                                | self.italic | self.underline | self.heading)

            self.insideBlockParser = (self.url | self.text | self.linebreak
                                      | self.link | self.noformat
                                      | self.preformat | self.bold_italic
                                      | self.bold | self.italic
                                      | self.underline)
        else:
            self.colorParser = self.text
            self.insideBlockParser = self.text

    def colorize(self, fullText):
        textlength = self._helper.calcByteLen(fullText)
        stylelist = [0] * textlength
        self._colorizeText(fullText, fullText, 0, textlength, self.colorParser,
                           stylelist)

        return stylelist

    def _colorizeText(self, fullText, text, start, end, parser, stylelist):
        tokens = parser.scanString(text[start:end])

        for token in tokens:
            if not self._runEvent.is_set():
                break

            pos_start = token[1] + start
            pos_end = token[2] + start

            tokenname = token[0].getName()

            if (tokenname == "text" or tokenname == "noformat"
                    or tokenname == "preformat"):
                if self._enableSpellChecking:
                    self._editor.runSpellChecking(stylelist, fullText,
                                                  pos_start, pos_end)
                continue

            if tokenname == "linebreak":
                continue

            # Нас интересует позиция в байтах, а не в символах
            bytepos_start = self._helper.calcBytePos(text, pos_start)
            bytepos_end = self._helper.calcBytePos(text, pos_end)

            # Применим стиль
            if tokenname == "bold":
                self._helper.addStyle(stylelist, self._editor.STYLE_BOLD_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(fullText, text,
                                   pos_start + len(BoldToken.start),
                                   pos_end - len(BoldToken.end),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "italic":
                self._helper.addStyle(stylelist, self._editor.STYLE_ITALIC_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(fullText, text,
                                   pos_start + len(ItalicToken.start),
                                   pos_end - len(ItalicToken.end),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "bold_italic":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_BOLD_ITALIC_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(fullText, text,
                                   pos_start + len(BoldItalicToken.start),
                                   pos_end - len(BoldItalicToken.end),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "underline":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_UNDERLINE_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(fullText, text,
                                   pos_start + len(UnderlineToken.start),
                                   pos_end - len(UnderlineToken.end),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "heading":
                self._helper.setStyle(stylelist, self._editor.STYLE_HEADING_ID,
                                      bytepos_start, bytepos_end)
                if self._enableSpellChecking:
                    self._editor.runSpellChecking(stylelist, fullText,
                                                  pos_start, pos_end)

            elif tokenname == "command":
                self._helper.setStyle(stylelist, self._editor.STYLE_COMMAND_ID,
                                      bytepos_start, bytepos_end)

            elif tokenname == "link":
                self._helper.addStyle(stylelist, self._editor.STYLE_LINK_ID,
                                      bytepos_start, bytepos_end)
                self._linkSpellChecking(fullText, text, stylelist, pos_start,
                                        pos_end)

            elif tokenname == "url":
                self._helper.addStyle(stylelist, self._editor.STYLE_LINK_ID,
                                      bytepos_start, bytepos_end)

    def _linkSpellChecking(self, fullText, text, stylelist, pos_start,
                           pos_end):
        separator1 = u'->'
        separator2 = u'|'

        link = text[pos_start:pos_end]
        sep1_pos = link.find(separator1)
        if sep1_pos != -1:
            if self._enableSpellChecking:
                self._editor.runSpellChecking(stylelist, fullText, pos_start,
                                              pos_start + sep1_pos)
            return

        sep2_pos = link.find(separator2)
        if sep2_pos != -1:
            if self._enableSpellChecking:
                self._editor.runSpellChecking(
                    stylelist, fullText,
                    pos_start + sep2_pos + len(separator2), pos_end)
Exemplo n.º 2
0
class WikiColorizer (object):
    def __init__ (self, editor, colorizeSyntax, enableSpellChecking, runEvent):
        self._editor = editor
        self._helper = TextEditorHelper()
        self._enableSpellChecking = enableSpellChecking
        self._runEvent = runEvent

        self.text = TextFactory.make (None)
        self.bold = FontsFactory.makeBold (None).setParseAction(lambda s, l, t: None)
        self.italic = FontsFactory.makeItalic (None).setParseAction(lambda s, l, t: None)
        self.bold_italic = FontsFactory.makeBoldItalic (None).setParseAction(lambda s, l, t: None)
        self.underline = FontsFactory.makeUnderline (None).setParseAction(lambda s, l, t: None)
        self.heading = HeadingFactory.make (None).setParseAction(lambda s, l, t: None)
        self.command = CommandFactory.make (None).setParseAction(lambda s, l, t: None)
        self.link = LinkFactory.make (None).setParseAction(lambda s, l, t: None)
        self.url = UrlFactory.make (None).setParseAction(lambda s, l, t: None)
        self.linebreak = LineBreakFactory.make (None).setParseAction(lambda s, l, t: None)
        self.noformat = NoFormatFactory.make (None).setParseAction(lambda s, l, t: None)
        self.preformat = PreFormatFactory.make (None).setParseAction(lambda s, l, t: None)

        if colorizeSyntax:
            self.colorParser = (
                self.url |
                self.text |
                self.linebreak |
                self.link |
                self.noformat |
                self.preformat |
                self.command |
                self.bold_italic |
                self.bold |
                self.italic |
                self.underline |
                self.heading)

            self.insideBlockParser = (
                self.url |
                self.text |
                self.linebreak |
                self.link |
                self.noformat |
                self.preformat |
                self.bold_italic |
                self.bold |
                self.italic |
                self.underline)
        else:
            self.colorParser = self.text
            self.insideBlockParser = self.text


    def colorize (self, fullText):
        textlength = self._helper.calcByteLen (fullText)
        stylelist = [0] * textlength
        self._colorizeText (fullText, fullText, 0, textlength, self.colorParser, stylelist)

        return stylelist


    def _colorizeText (self, fullText, text, start, end, parser, stylelist):
        tokens = parser.scanString (text[start: end])

        for token in tokens:
            if not self._runEvent.is_set():
                break

            pos_start = token[1] + start
            pos_end = token[2] + start

            tokenname = token[0].getName()

            if (tokenname == "text" or
                    tokenname == "noformat" or
                    tokenname == "preformat"):
                if self._enableSpellChecking:
                    self._editor.runSpellChecking (stylelist,
                                                   fullText,
                                                   pos_start,
                                                   pos_end)
                continue

            if tokenname == "linebreak":
                continue

            # Нас интересует позиция в байтах, а не в символах
            bytepos_start = self._helper.calcBytePos (text, pos_start)
            bytepos_end = self._helper.calcBytePos (text, pos_end)

            # Применим стиль
            if tokenname == "bold":
                self._helper.addStyle (stylelist,
                                       self._editor.STYLE_BOLD_ID,
                                       bytepos_start,
                                       bytepos_end)
                self._colorizeText (fullText,
                                    text,
                                    pos_start + len (BoldToken.start),
                                    pos_end - len (BoldToken.end),
                                    self.insideBlockParser, stylelist)

            elif tokenname == "italic":
                self._helper.addStyle (stylelist,
                                       self._editor.STYLE_ITALIC_ID,
                                       bytepos_start,
                                       bytepos_end)
                self._colorizeText (fullText,
                                    text,
                                    pos_start + len (ItalicToken.start),
                                    pos_end - len (ItalicToken.end),
                                    self.insideBlockParser, stylelist)

            elif tokenname == "bold_italic":
                self._helper.addStyle (stylelist,
                                       self._editor.STYLE_BOLD_ITALIC_ID,
                                       bytepos_start,
                                       bytepos_end)
                self._colorizeText (fullText,
                                    text,
                                    pos_start + len (BoldItalicToken.start),
                                    pos_end - len (BoldItalicToken.end),
                                    self.insideBlockParser, stylelist)

            elif tokenname == "underline":
                self._helper.addStyle (stylelist,
                                       self._editor.STYLE_UNDERLINE_ID,
                                       bytepos_start,
                                       bytepos_end)
                self._colorizeText (fullText,
                                    text,
                                    pos_start + len (UnderlineToken.start),
                                    pos_end - len (UnderlineToken.end),
                                    self.insideBlockParser,
                                    stylelist)

            elif tokenname == "heading":
                self._helper.setStyle (stylelist,
                                       self._editor.STYLE_HEADING_ID,
                                       bytepos_start,
                                       bytepos_end)
                if self._enableSpellChecking:
                    self._editor.runSpellChecking (stylelist,
                                                   fullText,
                                                   pos_start,
                                                   pos_end)

            elif tokenname == "command":
                self._helper.setStyle (stylelist,
                                       self._editor.STYLE_COMMAND_ID,
                                       bytepos_start,
                                       bytepos_end)

            elif tokenname == "link":
                self._helper.addStyle (stylelist,
                                       self._editor.STYLE_LINK_ID,
                                       bytepos_start,
                                       bytepos_end)
                self._linkSpellChecking (fullText,
                                         text,
                                         stylelist,
                                         pos_start,
                                         pos_end)

            elif tokenname == "url":
                self._helper.addStyle (stylelist,
                                       self._editor.STYLE_LINK_ID,
                                       bytepos_start,
                                       bytepos_end)


    def _linkSpellChecking (self, fullText, text, stylelist, pos_start, pos_end):
        separator1 = u'->'
        separator2 = u'|'

        link = text[pos_start: pos_end]
        sep1_pos = link.find (separator1)
        if sep1_pos != -1:
            if self._enableSpellChecking:
                self._editor.runSpellChecking (stylelist,
                                               fullText,
                                               pos_start,
                                               pos_start + sep1_pos)
            return

        sep2_pos = link.find (separator2)
        if sep2_pos != -1:
            if self._enableSpellChecking:
                self._editor.runSpellChecking (stylelist,
                                               fullText,
                                               pos_start + sep2_pos + len (separator2),
                                               pos_end)
Exemplo n.º 3
0
class MarkdownColorizer(object):
    def __init__(self, editor, colorizeSyntax, enableSpellChecking, runEvent):
        self._editor = editor
        self._helper = TextEditorHelper()
        self._enableSpellChecking = enableSpellChecking
        self._runEvent = runEvent

        self.text = TextFactory.make()
        self.bold = FontsFactory.makeBold()
        self.italic = FontsFactory.makeItalic()
        self.bold_italic = FontsFactory.makeBoldItalic()
        self.heading = HeadingFactory.make()
        self.link = LinkFactory.make()

        if colorizeSyntax:
            self.colorParser = (self.heading | self.text | self.link
                                | self.bold_italic | self.bold | self.italic)

            self.insideBlockParser = (self.text | self.link | self.bold_italic
                                      | self.bold | self.italic)
        else:
            self.colorParser = self.text
            self.insideBlockParser = self.text

    def colorize(self, fullText):
        textlength = self._helper.calcByteLen(fullText)
        stylelist = [0] * textlength
        self._colorizeText(fullText, fullText, 0, textlength, self.colorParser,
                           stylelist)

        return stylelist

    def _colorizeText(self, fullText, text, start, end, parser, stylelist):
        tokens = parser.scanString(text[start:end])

        for token in tokens:
            if not self._runEvent.is_set():
                break

            pos_start = token[1] + start
            pos_end = token[2] + start

            tokenname = token[0].getName()

            if (tokenname == "text" or tokenname == "noformat"
                    or tokenname == "preformat"):
                if self._enableSpellChecking:
                    self._editor.runSpellChecking(stylelist, fullText,
                                                  pos_start, pos_end)
                continue

            # Нас интересует позиция в байтах, а не в символах
            bytepos_start = self._helper.calcBytePos(text, pos_start)
            bytepos_end = self._helper.calcBytePos(text, pos_end)

            # Применим стиль
            if tokenname == "bold":
                self._helper.addStyle(stylelist, self._editor.STYLE_BOLD_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(fullText, text,
                                   pos_start + len(BoldToken.start_1),
                                   pos_end - len(BoldToken.end_1),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "italic":
                self._helper.addStyle(stylelist, self._editor.STYLE_ITALIC_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(fullText, text,
                                   pos_start + len(ItalicToken.start_1),
                                   pos_end - len(ItalicToken.end_1),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "bold_italic":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_BOLD_ITALIC_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(fullText, text,
                                   pos_start + len(BoldItalicToken.start),
                                   pos_end - len(BoldItalicToken.end),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "heading":
                self._helper.setStyle(stylelist, self._editor.STYLE_HEADING_ID,
                                      bytepos_start, bytepos_end)
                if self._enableSpellChecking:
                    self._editor.runSpellChecking(stylelist, fullText,
                                                  pos_start, pos_end)

            elif tokenname == "link":
                self._helper.addStyle(stylelist, self._editor.STYLE_LINK_ID,
                                      bytepos_start, bytepos_end)
                if self._enableSpellChecking:
                    self._linkSpellChecking(fullText, text, stylelist,
                                            pos_start, pos_end, token)

    def _linkSpellChecking(self, fullText, text, stylelist, pos_start, pos_end,
                           token):
        self._editor.runSpellChecking(stylelist, fullText, pos_start + 1,
                                      pos_start + 1 + len(token[0][0]))
        link = token[0][1]
        space_pos = link.find(u' ')
        if space_pos != -1:
            self._editor.runSpellChecking(
                stylelist, fullText,
                pos_start + 1 + len(token[0][0]) + 2 + space_pos, pos_start +
                1 + len(token[0][0]) + 2 + space_pos + len(token[0][1]))
Exemplo n.º 4
0
class MarkdownColorizer(object):
    def __init__(self, editor, colorizeSyntax, enableSpellChecking, runEvent):
        self._editor = editor
        self._helper = TextEditorHelper()
        self._enableSpellChecking = enableSpellChecking
        self._runEvent = runEvent

        self.text = TextFactory.make()
        self.bold = FontsFactory.makeBold()
        self.italic = FontsFactory.makeItalic()
        self.bold_italic = FontsFactory.makeBoldItalic()
        self.heading = HeadingFactory.make()
        self.link = LinkFactory.make()
        self.code = FontsFactory.makeCode()

        if colorizeSyntax:
            self.colorParser = (
                self.heading |
                self.text |
                self.link |
                self.bold_italic |
                self.bold |
                self.italic |
                self.code
            )

            self.insideBlockParser = (
                self.text |
                self.link |
                self.bold_italic |
                self.bold |
                self.italic
            )
        else:
            self.colorParser = self.text
            self.insideBlockParser = self.text

    def colorize(self, fullText):
        textlength = self._helper.calcByteLen(fullText)
        stylelist = [0] * textlength
        self._colorizeText(fullText,
                           fullText,
                           0,
                           textlength,
                           self.colorParser,
                           stylelist)

        return stylelist

    def _colorizeText(self, fullText, text, start, end, parser, stylelist):
        tokens = parser.scanString(text[start: end])

        for token in tokens:
            if not self._runEvent.is_set():
                break

            pos_start = token[1] + start
            pos_end = token[2] + start

            tokenname = token[0].getName()

            if (tokenname == "text" or
                    tokenname == "noformat" or
                    tokenname == "preformat"):
                if self._enableSpellChecking:
                    self._editor.runSpellChecking(stylelist,
                                                  fullText,
                                                  pos_start,
                                                  pos_end)
                continue

            # Нас интересует позиция в байтах, а не в символах
            bytepos_start = self._helper.calcBytePos(text, pos_start)
            bytepos_end = self._helper.calcBytePos(text, pos_end)

            # Применим стиль
            if tokenname == "bold":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_BOLD_ID,
                                      bytepos_start,
                                      bytepos_end)
                self._colorizeText(fullText,
                                   text,
                                   pos_start + len(BoldToken.start_1),
                                   pos_end - len(BoldToken.end_1),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "italic":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_ITALIC_ID,
                                      bytepos_start,
                                      bytepos_end)
                self._colorizeText(fullText,
                                   text,
                                   pos_start + len(ItalicToken.start_1),
                                   pos_end - len(ItalicToken.end_1),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "bold_italic":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_BOLD_ITALIC_ID,
                                      bytepos_start,
                                      bytepos_end)
                self._colorizeText(fullText,
                                   text,
                                   pos_start + len(BoldItalicToken.start),
                                   pos_end - len(BoldItalicToken.end),
                                   self.insideBlockParser, stylelist)

            elif tokenname == "heading":
                self._helper.setStyle(stylelist,
                                      self._editor.STYLE_HEADING_ID,
                                      bytepos_start,
                                      bytepos_end)
                if self._enableSpellChecking:
                    self._editor.runSpellChecking(stylelist,
                                                  fullText,
                                                  pos_start,
                                                  pos_end)

            elif tokenname == "link":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_LINK_ID,
                                      bytepos_start,
                                      bytepos_end)
                if self._enableSpellChecking:
                    self._linkSpellChecking(fullText,
                                            text,
                                            stylelist,
                                            pos_start,
                                            pos_end,
                                            token)

            elif tokenname == "code":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_COMMAND_ID,
                                      bytepos_start,
                                      bytepos_end)

    def _linkSpellChecking(self, fullText, text, stylelist,
                           pos_start, pos_end, token):
        self._editor.runSpellChecking(stylelist,
                                      fullText,
                                      pos_start + 1,
                                      pos_start + 1 + len(token[0][0]))
        link = token[0][1]
        space_pos = link.find(u' ')
        if space_pos != -1:
            self._editor.runSpellChecking(
                stylelist,
                fullText,
                pos_start + 1 + len(token[0][0]) + 2 + space_pos,
                pos_start + 1 + len(token[0][0]) + 2 + space_pos +
                len(token[0][1]))
Exemplo n.º 5
0
class MarkdownColorizer(object):
    def __init__(self, editor, colorizeSyntax, enableSpellChecking, runEvent):
        self._editor = editor
        self._helper = TextEditorHelper()
        self._enableSpellChecking = enableSpellChecking
        self._runEvent = runEvent

        self.text = TextFactory.make()
        self.bold = FontsFactory.makeBold()
        self.italic = FontsFactory.makeItalic()
        self.bold_italic = FontsFactory.makeBoldItalic()
        self.heading = HeadingFactory.make()
        self.link = LinkFactory.make()
        self.code = FontsFactory.makeCode()
        self.comment = FontsFactory.makeComment()

        if colorizeSyntax:
            self.colorParser = (self.heading | self.text | self.link
                                | self.bold_italic | self.bold | self.italic
                                | self.code | self.comment)

            self.insideBlockParser = (self.text | self.link | self.bold_italic
                                      | self.bold | self.italic | self.comment)
        else:
            self.colorParser = self.text
            self.insideBlockParser = self.text

    def colorize(self, text):
        textlength = self._helper.calcByteLen(text)
        stylelist = [0] * textlength
        spellStatusFlags = [True] * len(text)
        self._colorizeText(text, 0, textlength, self.colorParser, stylelist,
                           spellStatusFlags)
        wx.CallAfter(self._editor.markSpellErrors, spellStatusFlags)
        return stylelist

    def _checkSpell(self, text, start, end, spellStatusFlags):
        spellChecker = self._editor.getSpellChecker()
        errors = spellChecker.findErrors(text[start:end])

        for _word, err_start, err_end in errors:
            spellStatusFlags[err_start + start:err_end +
                             start] = [False] * (err_end - err_start)

    def _colorizeText(self, text, start, end, parser, stylelist,
                      spellStatusFlags):
        tokens = parser.scanString(text[start:end])

        for token in tokens:
            if not self._runEvent.is_set():
                break

            pos_start = token[1] + start
            pos_end = token[2] + start

            tokenname = token[0].getName()

            if (tokenname == "text" or tokenname == "noformat"
                    or tokenname == "preformat"):
                if self._enableSpellChecking:
                    self._checkSpell(text, pos_start, pos_end,
                                     spellStatusFlags)
                continue

            # Нас интересует позиция в байтах, а не в символах
            bytepos_start = self._helper.calcBytePos(text, pos_start)
            bytepos_end = self._helper.calcBytePos(text, pos_end)

            # Применим стиль
            if tokenname == "bold":
                self._helper.addStyle(stylelist, self._editor.STYLE_BOLD_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(text, pos_start + len(BoldToken.start_1),
                                   pos_end - len(BoldToken.end_1),
                                   self.insideBlockParser, stylelist,
                                   spellStatusFlags)

            elif tokenname == "italic":
                self._helper.addStyle(stylelist, self._editor.STYLE_ITALIC_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(text, pos_start + len(ItalicToken.start_1),
                                   pos_end - len(ItalicToken.end_1),
                                   self.insideBlockParser, stylelist,
                                   spellStatusFlags)

            elif tokenname == "bold_italic":
                self._helper.addStyle(stylelist,
                                      self._editor.STYLE_BOLD_ITALIC_ID,
                                      bytepos_start, bytepos_end)
                self._colorizeText(text,
                                   pos_start + len(BoldItalicToken.start),
                                   pos_end - len(BoldItalicToken.end),
                                   self.insideBlockParser, stylelist,
                                   spellStatusFlags)

            elif tokenname == "heading":
                self._helper.setStyle(stylelist, self._editor.STYLE_HEADING_ID,
                                      bytepos_start, bytepos_end)
                if self._enableSpellChecking:
                    self._checkSpell(text, pos_start, pos_end,
                                     spellStatusFlags)

            elif tokenname == "link":
                self._helper.addStyle(stylelist, self._editor.STYLE_LINK_ID,
                                      bytepos_start, bytepos_end)
                if self._enableSpellChecking:
                    self._linkSpellChecking(text, stylelist, spellStatusFlags,
                                            pos_start, pos_end, token)

            elif tokenname == "code":
                self._helper.addStyle(stylelist, self._editor.STYLE_COMMAND_ID,
                                      bytepos_start, bytepos_end)

            elif tokenname == "comment":
                self._helper.setStyle(stylelist, self._editor.STYLE_COMMENT_ID,
                                      bytepos_start, bytepos_end)
                if self._enableSpellChecking:
                    self._checkSpell(text, pos_start, pos_end,
                                     spellStatusFlags)

    def _linkSpellChecking(self, text, stylelist, spellStatusFlags, pos_start,
                           pos_end, token):
        self._checkSpell(text, pos_start + 1, pos_start + 1 + len(token[0][0]),
                         spellStatusFlags)
        link = token[0][1]
        space_pos = link.find(u' ')
        if space_pos != -1:
            self._checkSpell(
                text, pos_start + 1 + len(token[0][0]) + 2 + space_pos,
                pos_start + 1 + len(token[0][0]) + 2 + space_pos +
                len(token[0][1]), spellStatusFlags)