Skip to content

Commit

Permalink
Differentiate static and markdown files
Browse files Browse the repository at this point in the history
  • Loading branch information
marians committed Dec 13, 2024
1 parent 03d4cfc commit 4fba15d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,32 @@ jobs:
import sys
allowed_chars = re.compile(r'^[a-z0-9-\.+]+$')
allowed_chars_static = re.compile(r'^[a-z0-9-\._]+$') # images etc. may use the underscore
content_dir = 'src/content'
errors = []
for root, dirs, files in os.walk(content_dir):
for file in files:
full_path = Path(root, file)
if full_path.name == '_index.md':
continue
if not allowed_chars.match(full_path.stem):
errors.append(f"- {full_path}'\n")
if full_path.name == '_template.md.tpl':
continue
if full_path.suffix.lower() == '.md':
if not allowed_chars.match(full_path.stem):
errors.append(f"- FILE {full_path}'")
else:
# static files
if not allowed_chars_static.match(full_path.name):
errors.append(f"- FILE {full_path}'")
for dir in dirs:
if not allowed_chars.match(dir):
errors.append(f"- {Path(root, dir)}'\n")
errors.append(f"- DIR {Path(root, dir)}'")
if len(errors) > 0:
print("The following file/folder names use invalid characters. Only lowercase letters, digits, hyphens and period are allowed.\n\n")
print("The following file/folder names use invalid characters. Only lowercase letters, digits, hyphens and period are allowed.\n")
for error in errors:
print(error)
sys.exit(1)
Expand Down

0 comments on commit 4fba15d

Please sign in to comment.