File: fixMathInRst.py

package info (click to toggle)
expeyes 5.3.3%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 43,480 kB
  • sloc: python: 36,039; ansic: 9,754; xml: 1,010; makefile: 784; sh: 581; asm: 202; javascript: 46; php: 1
file content (14 lines) | stat: -rw-r--r-- 438 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import re, sys

t = ""
for fName in sys.argv[1:]:
    with open(fName) as infile:
        t=infile.read()

    if '\u2005' in t or '\u2212' in t or "⋯" in t:
        with  open(fName,"w") as outfile:
            t = re.sub('\u2212', ' ', t)
            t = re.sub(r'(:math:`.*)⋯([^`]*\`)', r'\1\\dots\2', t)
            outfile.write(re.sub('\u2005', ' ', t))

        print ("replaced non-ascii spaces by ordinary spaces in", fName)