##// END OF EJS Templates
Moved spoiler multiplier and space to module constants
neko259 -
r1460:402a9152 default
parent child Browse files
Show More
@@ -20,6 +20,9 b" MULTI_NEWLINES_PATTERN = re.compile(r'(\\"
20 ONE_NEWLINE = '\n'
20 ONE_NEWLINE = '\n'
21 REGEX_URL = re.compile(r'https?\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?')
21 REGEX_URL = re.compile(r'https?\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?')
22 LINE_BREAK_HTML = '<div class="br"></div>'
22 LINE_BREAK_HTML = '<div class="br"></div>'
23 SPOILER_SPACE = '&nbsp;'
24
25 MAX_SPOILER_MULTIPLIER = 2
23
26
24
27
25 class TextFormatter():
28 class TextFormatter():
@@ -169,8 +172,8 b' def render_tag(tag_name, value, options,'
169
172
170 def render_spoiler(tag_name, value, options, parent, context):
173 def render_spoiler(tag_name, value, options, parent, context):
171 text_len = len(value)
174 text_len = len(value)
172 space_count = random.randint(0, text_len * 2)
175 space_count = random.randint(0, text_len * MAX_SPOILER_MULTIPLIER)
173 side_spaces = '&nbsp;' * (space_count // 2)
176 side_spaces = SPOILER_SPACE * (space_count // 2)
174 return '<span class="spoiler">{}{}{}</span>'.format(side_spaces, value,
177 return '<span class="spoiler">{}{}{}</span>'.format(side_spaces, value,
175 side_spaces)
178 side_spaces)
176
179
General Comments 0
You need to be logged in to leave comments. Login now