mirror of https://github.com/docker/docs.git
fix: dockerfile tooltips should match only keywords
Before this change, the Dockerfile tooltip script marked all occurences of keywords, as defined by the lexer, as Dockerfile instructions in a `dockerfile` code block. This meant some tokens parsed from heredocs would be included. The matched keyword token is now compared against a hard-coded list of actual Dockerfile instructions before they're annotated. Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
parent
dbd27bd7c8
commit
91a2200a11
|
|
@ -1,4 +1,25 @@
|
|||
const cmds = document.querySelectorAll(".language-dockerfile span.k");
|
||||
const keywords = [
|
||||
"ADD",
|
||||
"ARG",
|
||||
"CMD",
|
||||
"COPY",
|
||||
"ENTRYPOINT",
|
||||
"ENV",
|
||||
"EXPOSE",
|
||||
"FROM",
|
||||
"HEALTHCHECK",
|
||||
"LABEL",
|
||||
// "MAINTAINER",
|
||||
"ONBUILD",
|
||||
"RUN",
|
||||
"SHELL",
|
||||
"STOPSIGNAL",
|
||||
"USER",
|
||||
"VOLUME",
|
||||
"WORKDIR",
|
||||
]
|
||||
const cmds = Array.from(document.querySelectorAll(".language-dockerfile span.k"))
|
||||
.filter((el) => keywords.some(kwd => el.textContent.includes(kwd)));
|
||||
|
||||
for (const cmd of cmds) {
|
||||
const name = cmd.textContent;
|
||||
|
|
|
|||
Loading…
Reference in New Issue