eric6/ThirdParty/Pygments/pygments/lexers/mime.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.lexers.mime 3 pygments.lexers.mime
4 ~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexer for Multipurpose Internet Mail Extensions (MIME) data. 6 Lexer for Multipurpose Internet Mail Extensions (MIME) data.
7 7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
56 mimetypes = ["multipart/mixed", 56 mimetypes = ["multipart/mixed",
57 "multipart/related", 57 "multipart/related",
58 "multipart/alternative"] 58 "multipart/alternative"]
59 59
60 def __init__(self, **options): 60 def __init__(self, **options):
61 super(MIMELexer, self).__init__(**options) 61 super().__init__(**options)
62 self.boundary = options.get("Multipart-Boundary") 62 self.boundary = options.get("Multipart-Boundary")
63 self.content_transfer_encoding = options.get("Content_Transfer_Encoding") 63 self.content_transfer_encoding = options.get("Content_Transfer_Encoding")
64 self.content_type = options.get("Content_Type", "text/plain") 64 self.content_type = options.get("Content_Type", "text/plain")
65 self.max_nested_level = get_int_opt(options, "MIME-max-level", -1) 65 self.max_nested_level = get_int_opt(options, "MIME-max-level", -1)
66 66
98 pos_body_start = match.start() 98 pos_body_start = match.start()
99 entire_body = match.group() 99 entire_body = match.group()
100 100
101 # skip first newline 101 # skip first newline
102 if entire_body[0] == '\n': 102 if entire_body[0] == '\n':
103 yield pos_body_start, Text.Whitespace, u'\n' 103 yield pos_body_start, Text.Whitespace, '\n'
104 pos_body_start = pos_body_start + 1 104 pos_body_start = pos_body_start + 1
105 entire_body = entire_body[1:] 105 entire_body = entire_body[1:]
106 106
107 # if it is not a mulitpart 107 # if it is not a mulitpart
108 if not self.content_type.startswith("multipart") or not self.boundary: 108 if not self.content_type.startswith("multipart") or not self.boundary:
174 self.content_type = match.group(1) 174 self.content_type = match.group(1)
175 175
176 prefix_len = match.start(1) - match.start(0) 176 prefix_len = match.start(1) - match.start(0)
177 yield match.start(0), Text.Whitespace, match.group(0)[:prefix_len] 177 yield match.start(0), Text.Whitespace, match.group(0)[:prefix_len]
178 yield match.start(1), Name.Label, match.group(2) 178 yield match.start(1), Name.Label, match.group(2)
179 yield match.end(2), String.Delimiter, u"/" 179 yield match.end(2), String.Delimiter, '/'
180 yield match.start(3), Name.Label, match.group(3) 180 yield match.start(3), Name.Label, match.group(3)
181 181
182 def get_content_type_subtokens(self, match): 182 def get_content_type_subtokens(self, match):
183 yield match.start(1), Text, match.group(1) 183 yield match.start(1), Text, match.group(1)
184 yield match.start(2), Text.Whitespace, match.group(2) 184 yield match.start(2), Text.Whitespace, match.group(2)

eric ide

mercurial