diff --git a/src/calibre/gui2/tweak_book/editor/syntax/html.py b/src/calibre/gui2/tweak_book/editor/syntax/html.py index 17e7b30b81..7fd7d0fa18 100644 --- a/src/calibre/gui2/tweak_book/editor/syntax/html.py +++ b/src/calibre/gui2/tweak_book/editor/syntax/html.py @@ -24,6 +24,7 @@ attribute_name_pat = re.compile(r'''[^%s"'/><=]+''' % space_chars) self_closing_pat = re.compile(r'/\s*>') unquoted_val_pat = re.compile(r'''[^%s'"=<>`]+''' % space_chars) cdata_close_pats = {x:re.compile(r''])] t = normal_pat.search(text, i).group() - fmt = None - if state.bold or state.italic: - fmt = QTextCharFormat() - if state.bold: - fmt.setFontWeight(QFont.Bold) - if state.italic: - fmt.setFontItalic(True) - return [(len(t), fmt)] + return mark_nbsp(state, t, formats['nbsp']) def opening_tag(state, text, i, formats): 'An opening tag, like ' @@ -257,6 +268,7 @@ class HTMLHighlighter(SyntaxHighlighter): 'string': t['String'], 'nsprefix': t['Constant'], 'preproc': t['PreProc'], + 'nbsp': t['CursorLine'], } for name, msg in { '<': _('An unescaped < is not allowed. Replace it with <'), @@ -314,10 +326,12 @@ if __name__ == '__main__':

A heading that should appear in bold, with an italic word

Some text with inline formatting, that is syntax highlighted. A bold word, and an italic word. \ -Some italic text with a bold italic word in middle.

+Some italic text with a bold-italic word in the middle.

+ +

Some\xa0words\xa0separated\xa0by\xa0non-breaking\xa0spaces.

''')