2929 - name : Copy CONTRIBUTING.md into docs
3030 run : |
3131 sed -i -e 's|./docs/||g' hyper/CONTRIBUTING.md
32- cp -a hyper/CONTRIBUTING.md hyper/docs
33-
32+ cp -a hyper/CONTRIBUTING.md hyper/docs/CONTRIBUTING.md
33+
3434 # Insert frontmatter borders, replace markdown header with
3535 # frontmatter title and insert layout: guide
3636 - name : Convert doc titles to frontmatter
@@ -49,23 +49,34 @@ jobs:
4949 sed -i -e '4i permalink: /contrib/' hyper/docs/README.md
5050 mv hyper/docs/README.md hyper/docs/index.md
5151
52- # Lowercase the internal links so they will correctly point to
53- # the lowercased filenames.
52+
53+ # Lowercase the internal links and replace underscores with
54+ # hyphens, so they will point to the correct file.
5455 - name : Lowercase internal links
5556 run : |
5657 for filename in hyper/docs/*.md; do
5758 # cut `.md` from the filename before search and replace
5859 filename=${filename::-3};
5960
6061 for file in hyper/docs/*.md; do
62+ # filename without parent path
63+ filename=${filename##*/}
64+
6165 # don't lowercase MSRV
62- if [[ "${filename##*/ }" == 'MSRV' ]]; then
66+ if [[ "${filename}" == 'MSRV' ]]; then
6367 continue
6468 fi
6569
66- # match instances of only the filename, not including
67- # the parent path, and convert them to lowercase
68- sed -i -e "s|${filename##*/}|\L\0|g" $file;
70+ # lowercase filenames
71+ sed -i -e "s|${filename}|${filename,,}|g" $file;
72+
73+ # match on the lowercased filename from here on
74+ lowercased=${filename,,}
75+
76+ hyphenated=${lowercased//_/-}
77+
78+ # replace underscores in internal links with hyphens
79+ sed -i -e "s|${lowercased}|${hyphenated}|g" $file;
6980 done
7081 done
7182
7586 mv -vn "$f" "$(echo "$f" | tr '[:upper:]' '[:lower:]' | tr '_' '-')";
7687 done
7788
78- - name : Copy docs to contrib
89+ - name : Copy the hyper docs to contrib
7990 run : |
8091 mkdir -p _contrib
8192 cp -a hyper/docs/. _contrib/
0 commit comments