Size: 189
Comment:
|
← Revision 3 as of 2018-06-22 10:27:20 ⇥
Size: 1305
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
Use https://tlwiki.org/?title=Tools#RScript with an insanely high line length like 5000 so that line breaks aren't added to the script for no reason. Then process out markup with regexes. | Use https://tlwiki.org/?title=Tools#RScript with an insanely high line length like 5000 so that line breaks aren't added to the script for no reason. Use also, to clean up control formatting (modify as needed): {{{#!python #!python import sys import re for name in sys.argv[1:]: if name[-4:] == ".txt": with open(name, "r", encoding="cp932") as f: for line in f: line = line.rstrip() line = re.sub(r"\^g\d\d\d", "", line) line = re.sub(r"\^[nm]", "", line) line = re.sub(r"\^s\d", "", line) line = re.sub(r"\^d\d", "", line) line = re.sub(r"^grpo_[a-z0-9]*", "", line) line = re.sub(r"^grpe", "", line) line = re.sub(r"^grpo", "", line) line = re.sub(r"^99", "", line) line = re.sub(r"\|([^\[]*)\[([^\]]*)\]", r"〈\1〉《\2》", line) forbidden = r"""~`@#$%^&*()_+-=[]\{}|;':,./<>?""" for c in forbidden: if c in line: print(line) exit() if line == "": continue print(line) }}} |
Use https://tlwiki.org/?title=Tools#RScript with an insanely high line length like 5000 so that line breaks aren't added to the script for no reason.
Use also, to clean up control formatting (modify as needed):
1 #!python
2 import sys
3 import re
4
5 for name in sys.argv[1:]:
6 if name[-4:] == ".txt":
7 with open(name, "r", encoding="cp932") as f:
8 for line in f:
9 line = line.rstrip()
10 line = re.sub(r"\^g\d\d\d", "", line)
11 line = re.sub(r"\^[nm]", "", line)
12 line = re.sub(r"\^s\d", "", line)
13 line = re.sub(r"\^d\d", "", line)
14 line = re.sub(r"^grpo_[a-z0-9]*", "", line)
15 line = re.sub(r"^grpe", "", line)
16 line = re.sub(r"^grpo", "", line)
17 line = re.sub(r"^99", "", line)
18 line = re.sub(r"\|([^\[]*)\[([^\]]*)\]", r"〈\1〉《\2》", line)
19
20 forbidden = r"""~`@#$%^&*()_+-=[]\{}|;':,./<>?"""
21
22 for c in forbidden:
23 if c in line:
24 print(line)
25 exit()
26 if line == "":
27 continue
28
29 print(line)