Differences between revisions 2 and 3
Revision 2 as of 2018-06-22 10:27:03
Size: 1343
Editor: weh
Comment:
Revision 3 as of 2018-06-22 10:27:20
Size: 1305
Editor: weh
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 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)

RScript (last edited 2018-06-22 10:27:20 by weh)