Skip to content

Commit

Permalink
fix: dockerfile tooltips should match only keywords
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dvdksn committed Jan 12, 2024
1 parent dbd27bd commit 91a2200
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion assets/js/src/tooltip.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 91a2200

Please sign in to comment.