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

Created script for header capitalization

parent 804112d5
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):
# 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("]"))])+line[(line.find("]")):]
if line.startswith('---') or line.startswith('==='):
prev_line = titlecase(prev_line[:(prev_line.find("]"))])+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):
# 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):
print()
print("-"+line,end="")
print("+"+titlecase(line[:(line.find("]"))])+line[(line.find("]")):],end="")
return_value = 1
if line.startswith('---') or line.startswith('==='):
if prev_line != titlecase(prev_line):
print()
print("-"+prev_line,end="")
print("+"+titlecase(prev_line[:(prev_line.find("]"))])+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.
Finish editing this message first!
Please register or to comment