mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
11741543da
commit
6e4c3e41dc
@@ -7,14 +7,14 @@ from markdown_include.include import IncludePreprocessor, MarkdownInclude
|
||||
|
||||
from zerver.lib.exceptions import InvalidMarkdownIncludeStatement
|
||||
|
||||
INC_SYNTAX = re.compile(r'\{!\s*(.+?)\s*!\}')
|
||||
INC_SYNTAX = re.compile(r"\{!\s*(.+?)\s*!\}")
|
||||
|
||||
|
||||
class MarkdownIncludeCustom(MarkdownInclude):
|
||||
def extendMarkdown(self, md: markdown.Markdown) -> None:
|
||||
md.preprocessors.register(
|
||||
IncludeCustomPreprocessor(md, self.getConfigs()),
|
||||
'include_wrapper',
|
||||
"include_wrapper",
|
||||
500,
|
||||
)
|
||||
|
||||
@@ -46,15 +46,15 @@ class IncludeCustomPreprocessor(IncludePreprocessor):
|
||||
with open(filename, encoding=self.encoding) as r:
|
||||
text = r.readlines()
|
||||
except Exception as e:
|
||||
print(f'Warning: could not find file {filename}. Error: {e}')
|
||||
lines[loc] = INC_SYNTAX.sub('', line)
|
||||
print(f"Warning: could not find file {filename}. Error: {e}")
|
||||
lines[loc] = INC_SYNTAX.sub("", line)
|
||||
raise InvalidMarkdownIncludeStatement(m.group(0).strip())
|
||||
|
||||
line_split = INC_SYNTAX.split(line)
|
||||
if len(text) == 0:
|
||||
text.append('')
|
||||
text.append("")
|
||||
for i in range(len(text)):
|
||||
text[i] = text[i].rstrip('\r\n')
|
||||
text[i] = text[i].rstrip("\r\n")
|
||||
text[0] = line_split[0] + text[0]
|
||||
text[-1] = text[-1] + line_split[2]
|
||||
lines = lines[:loc] + text + lines[loc + 1 :]
|
||||
|
||||
Reference in New Issue
Block a user