def create_formats(highlighter, add_css=True): t = highlighter.theme formats = { 'tag': t['Function'], 'end_tag': t['Function'], 'attr': t['Type'], 'tag_name' : t['Statement'], 'entity': t['Special'], 'error': t['Error'], 'comment': t['Comment'], 'special': t['Special'], 'string': t['String'], 'nsprefix': t['Constant'], 'preproc': t['PreProc'], 'nbsp': t['SpecialCharacter'], 'spell': t['SpellError'], } for name, msg in { '<': _('An unescaped < is not allowed. Replace it with <'), '&': _('An unescaped ampersand is not allowed. Replace it with &'), '>': _('An unescaped > is not allowed. Replace it with >'), '/': _('/ not allowed except at the end of the tag'), '?': _('Unknown character'), 'bad-closing': _('A closing tag must contain only the tag name and nothing else'), 'no-attr-value': _('Expecting an attribute value'), 'only-prefix': _('A tag name cannot end with a colon'), }.iteritems(): f = formats[name] = SyntaxTextCharFormat(formats['error']) f.setToolTip(msg) f = formats['title'] = SyntaxTextCharFormat() f.setFontWeight(QFont.Bold) if add_css: formats['css_sub_formats'] = create_css_formats(highlighter) return formats
def create_formats(highlighter, add_css=True): t = highlighter.theme formats = { 'tag': t['Function'], 'end_tag': t['Function'], 'attr': t['Type'], 'tag_name' : t['Statement'], 'entity': t['Special'], 'error': t['Error'], 'comment': t['Comment'], 'special': t['Special'], 'string': t['String'], 'nsprefix': t['Constant'], 'preproc': t['PreProc'], 'nbsp': t['SpecialCharacter'], } for name, msg in { '<': _('An unescaped < is not allowed. Replace it with <'), '&': _('An unescaped ampersand is not allowed. Replace it with &'), '>': _('An unescaped > is not allowed. Replace it with >'), '/': _('/ not allowed except at the end of the tag'), '?': _('Unknown character'), 'bad-closing': _('A closing tag must contain only the tag name and nothing else'), 'no-attr-value': _('Expecting an attribute value'), 'only-prefix': _('A tag name cannot end with a colon'), }.iteritems(): f = formats[name] = SyntaxTextCharFormat(formats['error']) f.setToolTip(msg) f = formats['title'] = SyntaxTextCharFormat() f.setFontWeight(QFont.Bold) if add_css: formats['css_sub_formats'] = create_css_formats(highlighter) return formats
def create_formats(highlighter, add_css=True): t = highlighter.theme formats = { 'tag': t['Function'], 'end_tag': t['Function'], 'attr': t['Type'], 'entity': t['Special'], 'error': t['Error'], 'comment': t['Comment'], 'special': t['Special'], 'string': t['String'], 'nsprefix': t['Constant'], 'preproc': t['PreProc'], 'nbsp': t['SpecialCharacter'], 'spell': t['SpellError'], } for name, msg in iteritems({ '<': _('An unescaped < is not allowed. Replace it with <'), '&': _('An unescaped ampersand is not allowed. Replace it with &'), '>': _('An unescaped > is not allowed. Replace it with >'), '/': _('/ not allowed except at the end of the tag'), '?': _('Unknown character'), 'bad-closing': _('A closing tag must contain only the tag name and nothing else'), 'no-attr-value': _('Expecting an attribute value'), 'only-prefix': _('A tag name cannot end with a colon'), }): f = formats[name] = syntax_text_char_format(formats['error']) f.setToolTip(msg) f = formats['title'] = syntax_text_char_format() f.setFontWeight(QFont.Weight.Bold) if add_css: formats['css_sub_formats'] = create_css_formats(highlighter) formats['spell'].setProperty(SPELL_PROPERTY, True) formats['class_attr'] = syntax_text_char_format(t['Special']) formats['class_attr'].setProperty(CLASS_ATTRIBUTE_PROPERTY, True) formats['class_attr'].setToolTip( _('Hold down the Ctrl key and click to open the first matching CSS style rule' )) formats['link'] = syntax_text_char_format(t['Link']) formats['link'].setProperty(LINK_PROPERTY, True) formats['link'].setToolTip( _('Hold down the Ctrl key and click to open this link')) formats['bad_link'] = syntax_text_char_format(t['BadLink']) formats['bad_link'].setProperty(LINK_PROPERTY, True) formats['bad_link'].setToolTip( _('This link points to a file that is not present in the book')) formats['tag_name'] = f = syntax_text_char_format(t['Statement']) f.setProperty(TAG_NAME_PROPERTY, True) return formats
def create_formats(highlighter, add_css=True): t = highlighter.theme formats = { 'tag': t['Function'], 'end_tag': t['Function'], 'attr': t['Type'], 'entity': t['Special'], 'error': t['Error'], 'comment': t['Comment'], 'special': t['Special'], 'string': t['String'], 'nsprefix': t['Constant'], 'preproc': t['PreProc'], 'nbsp': t['SpecialCharacter'], 'spell': t['SpellError'], } for name, msg in { '<': _('An unescaped < is not allowed. Replace it with <'), '&': _('An unescaped ampersand is not allowed. Replace it with &'), '>': _('An unescaped > is not allowed. Replace it with >'), '/': _('/ not allowed except at the end of the tag'), '?': _('Unknown character'), 'bad-closing': _('A closing tag must contain only the tag name and nothing else'), 'no-attr-value': _('Expecting an attribute value'), 'only-prefix': _('A tag name cannot end with a colon'), }.iteritems(): f = formats[name] = syntax_text_char_format(formats['error']) f.setToolTip(msg) f = formats['title'] = syntax_text_char_format() f.setFontWeight(QFont.Bold) if add_css: formats['css_sub_formats'] = create_css_formats(highlighter) formats['spell'].setProperty(SPELL_PROPERTY, True) formats['class_attr'] = syntax_text_char_format(t['Special']) formats['class_attr'].setProperty(CLASS_ATTRIBUTE_PROPERTY, True) formats['link'] = syntax_text_char_format(t['Link']) formats['link'].setProperty(LINK_PROPERTY, True) formats['link'].setToolTip(_('Hold down the Ctrl key and click to open this link')) formats['bad_link'] = syntax_text_char_format(t['BadLink']) formats['bad_link'].setProperty(LINK_PROPERTY, True) formats['bad_link'].setToolTip(_('This link points to a file that is not present in the book')) formats['tag_name'] = f = syntax_text_char_format(t['Statement']) f.setProperty(TAG_NAME_PROPERTY, True) return formats
def create_formats(highlighter, add_css=True): t = highlighter.theme formats = { "tag": t["Function"], "end_tag": t["Function"], "attr": t["Type"], "entity": t["Special"], "error": t["Error"], "comment": t["Comment"], "special": t["Special"], "string": t["String"], "nsprefix": t["Constant"], "preproc": t["PreProc"], "nbsp": t["SpecialCharacter"], "spell": t["SpellError"], } for name, msg in { "<": _("An unescaped < is not allowed. Replace it with <"), "&": _("An unescaped ampersand is not allowed. Replace it with &"), ">": _("An unescaped > is not allowed. Replace it with >"), "/": _("/ not allowed except at the end of the tag"), "?": _("Unknown character"), "bad-closing": _("A closing tag must contain only the tag name and nothing else"), "no-attr-value": _("Expecting an attribute value"), "only-prefix": _("A tag name cannot end with a colon"), }.iteritems(): f = formats[name] = syntax_text_char_format(formats["error"]) f.setToolTip(msg) f = formats["title"] = syntax_text_char_format() f.setFontWeight(QFont.Bold) if add_css: formats["css_sub_formats"] = create_css_formats(highlighter) formats["spell"].setProperty(SPELL_PROPERTY, True) formats["link"] = syntax_text_char_format(t["Link"]) formats["link"].setProperty(LINK_PROPERTY, True) formats["link"].setToolTip(_("Hold down the Ctrl key and click to open this link")) formats["bad_link"] = syntax_text_char_format(t["BadLink"]) formats["bad_link"].setProperty(LINK_PROPERTY, True) formats["bad_link"].setToolTip(_("This link points to a file that is not present in the book")) formats["tag_name"] = f = syntax_text_char_format(t["Statement"]) f.setProperty(TAG_NAME_PROPERTY, True) return formats
def create_formats(self): super(HTMLHighlighter, self).create_formats() self.css_formats = create_css_formats(self) self.state_class = self.create_state