Skip to content

fix(md): escape template literal characters in bash fence blocks - #1530

Open
reginaldalfret wants to merge 1 commit into
google:mainfrom
reginaldalfret:fix/reginald-zx-md-bash-template-escape
Open

reginaldalfret wants to merge 1 commit into
google:mainfrom
reginaldalfret:fix/reginald-zx-md-bash-template-escape

Conversation

@reginaldalfret

Copy link
Copy Markdown

Fixes #1529

Summary

In src/md.ts, bash code fences (```bash) are wrapped into JavaScript tagged template literals (await $...). When bash commands contain parameter expansions such as `${VAR}` or backticks for command substitution (e.g. date ``), the unescaped characters were interpreted as JS template interpolation or terminated the template literal early, leading to ReferenceError or `SyntaxError`.

Changes

  • Escaped \, `, and ${ in bash fence lines before embedding them in the template literal.
  • Verified that normal shell variables ($VAR) and command substitutions ($(cmd)) continue to pass through unmodified.
  • Added unit tests in test/md.test.ts to ensure ${...} and backtick expressions in bash fences are escaped and executed as intended shell syntax.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bash code blocks in markdown scripts break on ${VAR} and backtick substitution

1 participant