-
Notifications
You must be signed in to change notification settings - Fork 0
/
ninety84.py
58 lines (49 loc) · 1.99 KB
/
ninety84.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from pygments.lexer import RegexLexer
from pygments.style import Style
from pygments.token import Token
DisconsoleToken = Token.Disconsole
DshMarkdown = DisconsoleToken.Markdown
class ThemeColors:
focusHighlight = "bg:#35373C"
mainBg = "bg:#313338"
channelListBg = "bg:#2B2D31"
secondaryBg = "bg:#232428"
selectHighlight = "bg:#404249"
msgFocusHighlight = "bg:#2F3238"
msgMentionHighlight = "bg:#444037"
accent = "bg:#5865f2"
url = "fg:#00A8FC"
mentionTextHighlight = "bg:#4e4e74"
tc = ThemeColors()
class DisconsoleLexer(RegexLexer):
tokens = {
"root": [
(r'[a-zA-Z]*:\/\/(\S*)', DisconsoleToken.URL),
(r'<#(\d+)>', DisconsoleToken.MentionChannel),
(r'<@(\d+)>|@(everyone|here)', DisconsoleToken.MentionUser),
(r'<@&(\d+)>', DisconsoleToken.MentionRole),
# markdown
("(\\*|\\_){1}(^[\\n|\\*]$1{1})", DshMarkdown.Italic),
("(\\*){2}(^[\\n|\\*]$1{2})", DshMarkdown.Bold),
(r"(\*){3}+(\S+)(\*){3}+", DshMarkdown.ItaBold),
("(\\_){2}(^[\\n|\\_]$1{2})", DshMarkdown.Underline),
(r"(\_){3}+(\S+)(\_){3}+", DshMarkdown.UnderItalic),
(r'\`([^(`|\n)]+)`', DshMarkdown.InlineCodeblock),
(r'`{3}\n(.+)\n`{3}', DshMarkdown.MultilineCodeblock),
(r'\[[^\[|\]]+\]\([a-zA-Z]*:\/\/(\S*)\)', DshMarkdown.URL)
]
}
class DisconsoleStyle(Style):
styles = {
DisconsoleToken.URL: tc.url.replace("fg:",""),
DisconsoleToken.MentionChannel: tc.mentionTextHighlight,
DisconsoleToken.MentionUser: tc.mentionTextHighlight,
DshMarkdown.Italic: "italic",
DshMarkdown.Bold: "bold",
DshMarkdown.ItaBold: "italic bold",
DshMarkdown.Underline: "underline",
DshMarkdown.UnderItalic: "underline italic",
DshMarkdown.InlineCodeblock: tc.channelListBg,
DshMarkdown.MultilineCodeblock: tc.channelListBg,
DshMarkdown.URL: tc.url.replace("fg:",""),
}