20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
if [[ ! -d "${base_dir}" ]]; then
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: ${base_dir} not a directory!" >&2
exit 1
fi
# Root folder: remove leading / from href and src attributes
# Works across (and preserves) line breaks introduced by the `tidy` command
perl -0777 -i -pe 's/ href=(\s*)"\// href=$1"/ig' "${base_dir}"*.html
perl -0777 -i -pe 's/ src=(\s*)"\// src=$1"/ig' "${base_dir}"*.html
# subfolders: replace leading / with ../ in href and src attributes
perl -0777 -i -pe 's/ href=(\s*)"\// href=$1"..\//ig' "${base_dir}"articles/*.html
perl -0777 -i -pe 's/ src=(\s*)"\// src=$1"..\//ig' "${base_dir}"articles/*.html
perl -0777 -i -pe 's/ href=(\s*)"\// href=$1"..\//ig' "${base_dir}"series/*.html
perl -0777 -i -pe 's/ src=(\s*)"\// src=$1"..\//ig' "${base_dir}"series/*.html
|
|
|
|
|
|
|
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
if [[ ! -d "${base_dir}" ]]; then
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: ${base_dir} not a directory!" >&2
exit 1
fi
# Root folder: remove leading / from href and src attributes
# Works across (and preserves) line breaks introduced by the `tidy` command
perl -0777 -i -pe 's/ href=(\s*)"\/(?!code)/ href=$1"/ig' "${base_dir}"*.html
perl -0777 -i -pe 's/ src=(\s*)"\/(?!code)/ src=$1"/ig' "${base_dir}"*.html
# subfolders: replace leading / with ../ in href and src attributes
perl -0777 -i -pe 's/ href=(\s*)"\/(?!code)/ href=$1"..\//ig' "${base_dir}"articles/*.html
perl -0777 -i -pe 's/ src=(\s*)"\/(?!code)/ src=$1"..\//ig' "${base_dir}"articles/*.html
perl -0777 -i -pe 's/ href=(\s*)"\/(?!code)/ href=$1"..\//ig' "${base_dir}"series/*.html
perl -0777 -i -pe 's/ src=(\s*)"\/(?!code)/ src=$1"..\//ig' "${base_dir}"series/*.html
|