init
Browse files
kowiki.py
CHANGED
@@ -58,7 +58,15 @@ def replace_link(text):
|
|
58 |
text = re.sub("\[youtube\([^\]]+\)\]", "[YOUTUBE LINK]", text)
|
59 |
return text
|
60 |
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
def process_text(text: str):
|
63 |
if not isinstance(text, str):
|
64 |
return ""
|
@@ -70,12 +78,7 @@ def process_text(text: str):
|
|
70 |
text = re.sub("'''", "", text)
|
71 |
text = replace_link(text)
|
72 |
text = remove_attribute_in_table(text)
|
73 |
-
|
74 |
-
while True:
|
75 |
-
new_text = re.sub("\{\{[^\{\}\|]+\}\}", "", text)
|
76 |
-
if new_text == text:
|
77 |
-
break
|
78 |
-
text = new_text
|
79 |
text = re.sub("\n{2,}", "\n\n", text)
|
80 |
text = re.sub("\t{2,}", "\t\t", text)
|
81 |
text = re.sub("[0-9]+px\|sub\|link[^\n]+", "", text)
|
|
|
58 |
text = re.sub("\[youtube\([^\]]+\)\]", "[YOUTUBE LINK]", text)
|
59 |
return text
|
60 |
|
61 |
+
def remove_double_bracket_text(text):
|
62 |
+
new_text = ""
|
63 |
+
while True:
|
64 |
+
new_text = re.sub("\{\{[^\{\}\|]+\}\}", "", text)
|
65 |
+
if new_text == text:
|
66 |
+
break
|
67 |
+
text = new_text
|
68 |
+
text = re.sub("\{\{[^\{\}\|]+\|([^\{\}]+)\}\}", "\\1", text)
|
69 |
+
return text
|
70 |
def process_text(text: str):
|
71 |
if not isinstance(text, str):
|
72 |
return ""
|
|
|
78 |
text = re.sub("'''", "", text)
|
79 |
text = replace_link(text)
|
80 |
text = remove_attribute_in_table(text)
|
81 |
+
text = remove_double_bracket_text(text)
|
|
|
|
|
|
|
|
|
|
|
82 |
text = re.sub("\n{2,}", "\n\n", text)
|
83 |
text = re.sub("\t{2,}", "\t\t", text)
|
84 |
text = re.sub("[0-9]+px\|sub\|link[^\n]+", "", text)
|