◊(Local Yarn Code "Check-in [fcaf9eac]")

Overview
Comment:Make relativize script play nice with tidy-introduced line breaks
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fcaf9eac27ccdbe1ad9d266df8c7f9262359e5590fefe9e47459016fa1513908
User & Date: joel on 2020-02-29 15:51:18
Other Links: manifest | tags
Context
2020-02-29
16:12
Implement excerpts ([10e20e5ab65]) check-in: 8af3b9ce user: joel tags: trunk
15:51
Make relativize script play nice with tidy-introduced line breaks check-in: fcaf9eac user: joel tags: trunk
2020-02-26
01:15
Don't recompute article ids every time check-in: 49e661b8 user: joel tags: trunk
Changes

Modified util/relativize from [7e87490d] to [720591c3].

19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
# Ensure directory exists
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
sed -i '' -- 's/href=\"\//href=\"/g' "${base_dir}"*.html
sed -i '' -- 's/src=\"\//src=\"/g' "${base_dir}"*.html


# subfolders: replace leading / with ../ in href and src attributes
sed -i '' -- 's/href=\"\//href=\"..\//g' "${base_dir}"articles/*.html
sed -i '' -- 's/src=\"\//src=\"..\//g' "${base_dir}"articles/*.html
sed -i '' -- 's/href=\"\//href=\"..\//g' "${base_dir}"series/*.html
sed -i '' -- 's/src=\"\//src=\"..\//g' "${base_dir}"series/*.html







|
|
>


|
|
|
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Ensure directory exists
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