mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Highlight class attributes inside HTML tags
Rather than using a special highlighting group, use the same style as that used for classes in the css syntax.
This commit is contained in:
parent
25de034110
commit
069c74563c
@ -46,6 +46,7 @@ SPELL_LOCALE_PROPERTY = SPELL_PROPERTY + 1
|
||||
LINK_PROPERTY = SPELL_LOCALE_PROPERTY + 1
|
||||
TAG_NAME_PROPERTY = LINK_PROPERTY + 1
|
||||
CSS_PROPERTY = TAG_NAME_PROPERTY + 1
|
||||
CLASS_ATTRIBUTE_PROPERTY = CSS_PROPERTY + 1
|
||||
|
||||
def syntax_text_char_format(*args):
|
||||
ans = QTextCharFormat(*args)
|
||||
|
@ -18,7 +18,7 @@ from calibre.spell.break_iterator import split_into_words_and_positions
|
||||
from calibre.gui2.tweak_book import dictionaries, tprefs, verify_link
|
||||
from calibre.gui2.tweak_book.editor import (
|
||||
syntax_text_char_format, SPELL_PROPERTY, SPELL_LOCALE_PROPERTY,
|
||||
store_locale, LINK_PROPERTY, TAG_NAME_PROPERTY)
|
||||
store_locale, LINK_PROPERTY, TAG_NAME_PROPERTY, CLASS_ATTRIBUTE_PROPERTY)
|
||||
from calibre.gui2.tweak_book.editor.syntax.base import SyntaxHighlighter, run_loop
|
||||
from calibre.gui2.tweak_book.editor.syntax.css import (
|
||||
create_formats as create_css_formats, state_map as css_state_map, CSSState, CSSUserData)
|
||||
@ -535,7 +535,8 @@ def create_formats(highlighter, add_css=True):
|
||||
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.get('ClassAttribute', t['String']))
|
||||
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'))
|
||||
|
@ -71,7 +71,6 @@ SOLARIZED = \
|
||||
Tooltip fg=black bg=ffffed
|
||||
Link fg={blue}
|
||||
BadLink fg={cyan} us=wave uc={red}
|
||||
ClassAttribute fg={cyan}
|
||||
|
||||
DiffDelete bg={base02} fg={red}
|
||||
DiffInsert bg={base02} fg={green}
|
||||
@ -109,13 +108,12 @@ THEMES = {
|
||||
Type fg={identifier}
|
||||
Statement fg={keyword}
|
||||
Keyword fg={keyword}
|
||||
Special fg=e7f6da
|
||||
Special fg={special}
|
||||
Error us=wave uc=red
|
||||
SpellError us=wave uc=orange
|
||||
SpecialCharacter bg={cursor_loc}
|
||||
Link fg=cyan
|
||||
BadLink fg={string} us=wave uc=red
|
||||
ClassAttribute fg={string}
|
||||
|
||||
DiffDelete bg=341414 fg=642424
|
||||
DiffInsert bg=143414 fg=246424
|
||||
@ -128,7 +126,8 @@ THEMES = {
|
||||
comment='99968b',
|
||||
string='95e454',
|
||||
keyword='8ac6f2',
|
||||
constant='e5786d'), # }}}
|
||||
constant='e5786d',
|
||||
special='e7f6da'), # }}}
|
||||
|
||||
'pyte-light': # {{{
|
||||
'''
|
||||
@ -158,13 +157,12 @@ THEMES = {
|
||||
Type fg={identifier}
|
||||
Statement fg={keyword}
|
||||
Keyword fg={keyword}
|
||||
Special fg=70a0d0 italic
|
||||
Special fg={special} italic
|
||||
SpecialCharacter bg={cursor_loc}
|
||||
Error us=wave uc=red
|
||||
SpellError us=wave uc=magenta
|
||||
Link fg=blue
|
||||
BadLink fg={string} us=wave uc=red
|
||||
ClassAttribute fg={string}
|
||||
|
||||
DiffDelete bg=rgb(255,180,200) fg=rgb(200,80,110)
|
||||
DiffInsert bg=rgb(180,255,180) fg=rgb(80,210,80)
|
||||
@ -177,7 +175,8 @@ THEMES = {
|
||||
comment='a0b0c0',
|
||||
string='4070a0',
|
||||
keyword='007020',
|
||||
constant='a07040'), # }}}
|
||||
constant='a07040',
|
||||
special='70a0d0'), # }}}
|
||||
|
||||
'solarized-x-dark': SOLARIZED.format(**SLDX),
|
||||
'solarized-dark': SOLARIZED.format(**SLD),
|
||||
@ -569,7 +568,7 @@ class ThemeEditor(Dialog):
|
||||
*['<b>%s</b>' % x for x in (
|
||||
'Normal', 'Visual', 'CursorLine', 'LineNr', 'MatchParen',
|
||||
'Function', 'Type', 'Statement', 'Constant', 'SpecialCharacter',
|
||||
'Error', 'SpellError', 'Comment', 'ClassAttribute'
|
||||
'Error', 'SpellError', 'Comment'
|
||||
)]
|
||||
))
|
||||
p.setMaximumWidth(p.size_hint.width() + 5)
|
||||
|
Loading…
x
Reference in New Issue
Block a user