Skip to content
Snippets Groups Projects
Commit 40a389fd authored by Lubomir Prda's avatar Lubomir Prda
Browse files

Merge branch 'capitalize' into 'master'

Capitalize

Closes #31

See merge request !65
parents dea6f6aa b2c7e45f
No related branches found
No related tags found
5 merge requests!368Update prace.md to document the change from qprace to qprod as the default...,!367Update prace.md to document the change from qprace to qprod as the default...,!366Update prace.md to document the change from qprace to qprod as the default...,!323extended-acls-storage-section,!65Capitalize
Pipeline #
......@@ -19,6 +19,13 @@ two spaces:
- echo "== Files having more than one space betwee two characters =="
- find docs.it4i/ -name '*.md' -exec grep "[[:alpha:]] [[:alpha:]]" -l {} +
capitalize:
stage: test
image: davidhrbac/docker-mkdocscheck:latest
allow_failure: true
script:
- find docs.it4i/ -name '*.md' -print0 | xargs -0 -n1 scripts/titlemd_test.py
spell check:
stage: test
image: davidhrbac/docker-npmcheck:latest
......
#!/usr/bin/python
import fnmatch
import os
import sys
try:
from titlecase import titlecase
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()
with open(location, 'w') as f:
# Loop through the list of lines and titlecase
# any line beginning with '#'.
prev_line = lines.pop(0)
disabled = 0
for line in lines:
if line.startswith("``") and disabled == 0:
disabled = 1
else:
if line.startswith("``") and disabled == 1:
disabled = 0
if line.startswith('#') and disabled == 0:
line = titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):]
if line.startswith('---') or line.startswith('==='):
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)
if __name__ == "__main__":
try:
main(sys.argv[1])
except IndexError:
main('.')
#!/usr/bin/env python
from __future__ import print_function
import fnmatch
import os
import sys
try:
from titlecase import titlecase
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()
# Loop through the list of lines and titlecase
# any line beginning with '#'.
return_value = 0
prev_line = lines.pop(0)
disabled = 0
print(`location`)
for line in lines:
if line.startswith("``") and disabled == 0:
disabled = 1
else:
if line.startswith("``") and disabled == 1:
disabled = 0
if line.startswith('#') and disabled == 0:
if line != titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):]:
print()
print("-"+line,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[:(prev_line.find("]"))], callback=abbreviations)+prev_line[(prev_line.find("]")):]:
print()
print("-"+prev_line,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:
print("==Ok==")
exit(return_value)
if __name__ == "__main__":
try:
main(sys.argv[1])
except IndexError:
main('.')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment