diff --git a/docs/Dockerfile b/docs/Dockerfile index 0ed4e526..a1b9a14a 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -1,26 +1,23 @@ FROM docs/base:latest MAINTAINER Mary Anthony (@moxiegirl) +ENV PROJECT=registry + # To get the git info for this repo COPY . /src -COPY . /docs/content/registry/ +COPY . /docs/content/$PROJECT/ -# Sed to process GitHub Markdown -# 1-2 Remove comment code from metadata block -# 3 Change ](/word to ](/project/ in links -# 4 Change ](word.md) to ](/project/word) -# 5 Remove .md extension from link text -# 6 Change ](./ to ](/project/word) -# 7 Change ](../../ to ](/project/ -# 8 Change ](../ to ](/project/ -# -RUN find /docs/content/registry -type f -name "*.md" -exec sed -i.old \ - -e '/^/g' \ - -e '/^/g' \ - -e 's/\(\]\)\([(]\)\(\/\)/\1\2\/registry\//g' \ - -e 's/\(\][(]\)\([A-Za-z0-9]*\)\(\.md\)/\1\/registry\/\2/g' \ - -e 's/\([(]\)\(.*\)\(\.md\)/\1\2/g' \ - -e 's/\(\][(]\)\(\.\/\)/\1\/registry\//g' \ - -e 's/\(\][(]\)\(\.\.\/\.\.\/\)/\1\/registry\//g' \ - -e 's/\(\][(]\)\(\.\.\/\)/\1\/registry\//g' {} \; \ No newline at end of file +# Processing GitHub Markdown +# 1 Remove +# 2 Remove any leading combination of dots and slashes (./, ../, ../../, etc) +# 3 Prepend /$PROJECT to all links, remove any trailing .md, only for non http:// links and non internal anchors + +RUN find /docs/content/$PROJECT -type f -name "*.md" -not -name "*.compare.md" -exec sed -i.old \ + -e '/^/g' \ + -e 's/\(\][(]\)\(\.*\/\)*/\1/g' \ + -e 's/\(\][(]\)\([A-Za-z0-9_/-]\{1,\}\)\(\.md\)\{0,1\}\(#\{0,1\}\(#[A-Za-z0-9_-]*\)\{0,1\}\)[)]/\1\/'$PROJECT'\/\2\4)/g' \ + {} \; + +# Prepare the compare file and expect an empty diff against test.md +RUN sed -i.old -e 's/\/placeholder\//\/'$PROJECT'\//g' /docs/content/$PROJECT/test.compare.md && diff -u /docs/content/$PROJECT/test.md /docs/content/$PROJECT/test.compare.md diff --git a/docs/test.compare.md b/docs/test.compare.md new file mode 100644 index 00000000..86087a15 --- /dev/null +++ b/docs/test.compare.md @@ -0,0 +1,16 @@ + +WHATEVER + + +WHATEVER AGAIN + + +[display11](/placeholder/link-1) [display12](/placeholder/link_2) [display13](/placeholder/link/3) +[display21](/placeholder/link-1) [display22](/placeholder/link_2) [display23](/placeholder/link/3) +[display31.md](/placeholder/link-1) [display32.md](/placeholder/link_2) [display33.md](/placeholder/link/3) +[display41](/placeholder/link-1) [display42](/placeholder/link_2) [display43](/placeholder/link/3) +[display51](/placeholder/link-1) [display52](/placeholder/link_2) [display53](/placeholder/link/3) +[display61](/placeholder/link-1) [display62](/placeholder/link_2) [display63](/placeholder/link/3) +[display71](/placeholder/link-1#something-else) [display62](/placeholder/link_2#else) [display63](#else) + +[dont-touch](https://somewhere/foo.md#dont) [dont-touch](https://somewhere/foo.md#dont) diff --git a/docs/test.md b/docs/test.md new file mode 100644 index 00000000..3c139cb3 --- /dev/null +++ b/docs/test.md @@ -0,0 +1,16 @@ + + + +[display11](/link-1) [display12](/link_2) [display13](/link/3) +[display21](link-1.md) [display22](link_2.md) [display23](link/3.md) +[display31.md](link-1.md) [display32.md](link_2.md) [display33.md](link/3.md) +[display41](./link-1.md) [display42](./link_2.md) [display43](./link/3.md) +[display51](../link-1.md) [display52](../link_2.md) [display53](../link/3.md) +[display61](../../link-1.md) [display62](../../link_2.md) [display63](../../link/3.md) +[display71](link-1.md#something-else) [display62](link_2#else) [display63](#else) + +[dont-touch](https://somewhere/foo.md#dont) [dont-touch](https://somewhere/foo.md#dont)