diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index a4ad5bdd..8c648816 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -43,7 +43,7 @@ jobs: uses: actions/configure-pages@v2 - name: Build with Jekyll # Outputs to the './_site' directory by default - run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" + run: docker/build/run.sh --baseurl "${{ steps.pages.outputs.base_path }}" env: JEKYLL_ENV: production - name: Upload artifact diff --git a/docker/build/replace-tags.py b/docker/build/replace-tags.py new file mode 100644 index 00000000..860ce858 --- /dev/null +++ b/docker/build/replace-tags.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import os +import re + +# Path to output directory +path_to_html_files = '_site/' + +# Match tag +pattern = re.compile(r'<(source|img|br)(.*?) />') + +# Iterate through HTML files +for subdir, dirs, files in os.walk(path_to_html_files): + for file_name in files: + if file_name.endswith('.html'): + file_path = os.path.join(subdir, file_name) + + # Read a file + with open(file_path, 'r') as file: + file_data = file.read() + + # Strip out closing slashes + #file_data = file_data.replace('
', '
') + file_data = pattern.sub(r'<\1\2>', file_data) + + # Write changes back to file + with open(file_path, 'w') as file: + file.write(file_data) + +print("Finished removing closing slashes from void elements.") diff --git a/docker/build/run.sh b/docker/build/run.sh index bba8138e..7a04d0fd 100755 --- a/docker/build/run.sh +++ b/docker/build/run.sh @@ -33,5 +33,7 @@ case "${1}" in jekyll serve ${LIVERELOAD} -H 0.0.0.0 $@ ;; *) # Pass through any other specified arguments - jekyll build -d _site $@ ;; + bundle exec jekyll build -d _site $@ + # Remove closing slashes from void elements + python3 docker/build/replace-tags.py ;; esac