Skip to content
This repository was archived by the owner on Aug 20, 2023. It is now read-only.

Commit bae7341

Browse files
committed
Fix KeyError for some languages without proper styles
1 parent 4214742 commit bae7341

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

codehighlighter/description.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:l = "http://libreoffice.org/extensions/description/2011"
55
xmlns:xlink="http://www.w3.org/1999/xlink"
66
>
7-
<version value="20170502.0.1"/>
7+
<version value="1.1"/>
88
<identifier value="javahelps.codehighlighter"/>
99

1010
<icon>

codehighlighter/python/highlight.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ def highlight_code(style, lang, codebox):
5959
cursor.gotoStart(False)
6060
for tok_type, tok_value in lexer.get_tokens(code):
6161
cursor.goRight(len(tok_value), True) # selects the token's text
62-
cursor.CharColor = to_rgbint(style.style_for_token(tok_type)['color'])
63-
cursor.goRight(0, False) # deselects the selected text
62+
try:
63+
cursor.CharColor = to_rgbint(style.style_for_token(tok_type)['color'])
64+
except Exception as e:
65+
pass
66+
finally:
67+
cursor.goRight(0, False) # deselects the selected text
6468

6569

6670
def highlight_abap_default(*args):

0 commit comments

Comments
 (0)