Skip to content

Commit 0a5cd83

Browse files
highlighter: Move fmt init outside the if as it's repeated (#669)
1 parent a609ad0 commit 0a5cd83

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ReText/highlighter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,20 @@ class ReTextHighlighter(QSyntaxHighlighter):
157157
)
158158

159159
def highlightBlock(self, text):
160+
# If inside fenced code block (not the fence line)
160161
if self.docType == 'Markdown' and self.previousBlockState() == 1:
162+
fmt = QTextCharFormat()
163+
fmt.setFontItalic(True)
164+
161165
# Check if this line closes fenced block
162166
if reFencedCodeEnd.match(text):
163167
# Fence closes: highlight fence line in yellowgreen (codeSpans)
164-
fmt = QTextCharFormat()
165168
fmt.setForeground(getColor('codeSpans')) # fence color yellowgreen
166-
fmt.setFontItalic(True)
167169
self.setFormat(0, len(text), fmt)
168170
self.setCurrentBlockState(0)
169171
else:
170172
# Inside fenced code: highlight in orange (codeBlock)
171-
fmt = QTextCharFormat()
172173
fmt.setForeground(getColor('codeBlock')) # code block content color orange
173-
fmt.setFontItalic(True)
174174
self.setFormat(0, len(text), fmt)
175175
self.setCurrentBlockState(1)
176176
return

0 commit comments

Comments
 (0)