Commit b2c7e45f authored by Lubomir Prda's avatar Lubomir Prda

capitalize now checks abbrevations from .spelling

parent 72ebc18f
......@@ -10,6 +10,14 @@ except ImportError:
print("Please install titlecase")
def main(location):
# Spelling exceptions
with open('.spelling') as f:
spelling = f.readlines()
def abbreviations(word, **kwargs):
if word+"\n" in spelling:
return word
# Open the file and read the lines as a list
with open(location) as f:
lines = f.readlines()
......@@ -26,9 +34,9 @@ def main(location):
if line.startswith("``") and disabled == 1:
disabled = 0
if line.startswith('#') and disabled == 0:
line = titlecase(line[:(line.find("]"))])+line[(line.find("]")):]
line = titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):]
if line.startswith('---') or line.startswith('==='):
prev_line = titlecase(prev_line[:(prev_line.find("]"))])+prev_line[(prev_line.find("]")):]
prev_line = titlecase(prev_line[:(prev_line.find("]"))], callback=abbreviations)+prev_line[(prev_line.find("]")):]
f.write(prev_line)
prev_line = line
f.write(prev_line)
......
......@@ -11,6 +11,14 @@ except ImportError:
print("Please install titlecase")
def main(location):
# Spelling exceptions
with open('.spelling') as f:
spelling = f.readlines()
def abbreviations(word, **kwargs):
if word+"\n" in spelling:
return word
# Open the file and read the lines as a list
with open(location) as f:
lines = f.readlines()
......@@ -28,16 +36,16 @@ def main(location):
if line.startswith("``") and disabled == 1:
disabled = 0
if line.startswith('#') and disabled == 0:
if line != titlecase(line):
if line != titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):]:
print()
print("-"+line,end="")
print("+"+titlecase(line[:(line.find("]"))])+line[(line.find("]")):],end="")
print("+"+titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):],end="")
return_value = 1
if line.startswith('---') or line.startswith('==='):
if prev_line != titlecase(prev_line):
if prev_line != titlecase(prev_line[:(prev_line.find("]"))], callback=abbreviations)+prev_line[(prev_line.find("]")):]:
print()
print("-"+prev_line,end="")
print("+"+titlecase(prev_line[:(prev_line.find("]"))])+prev_line[(prev_line.find("]")):],end="")
print("+"+titlecase(prev_line[:(prev_line.find("]"))], callback=abbreviations)+prev_line[(prev_line.find("]")):],end="")
return_value = 1
prev_line = line
if return_value == 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment