Skip to content

(#440) Fix dynamic code block issue with regex#464

Merged
st3phhays merged 3 commits into
chocolatey:mainfrom
alexaveldanez:dynamic-code-block-fixes
Jun 18, 2025
Merged

(#440) Fix dynamic code block issue with regex#464
st3phhays merged 3 commits into
chocolatey:mainfrom
alexaveldanez:dynamic-code-block-fixes

Conversation

@alexaveldanez

@alexaveldanez alexaveldanez commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Description Of Changes

Added regex to find exact match when doing a replace all in the dynamic code block.

Motivation and Context

This is necessary to fix issue where having multiple dynamic code block inputs on a page and one input name or variable has no number but other inputs do have a number in the name attribute variable it was causing the find and replace functionality in the dynamic code block component to break.

Testing

  1. Pull down the branch locally by running gh pr checkout
  2. From the local repository run yarn build.
  3. In local docs repository run yarn link choco-theme.
  4. Open any docs .mdx file.
  5. Add imports for <DynamicCodeBlockInput /> and <DynamicCodeBlock /> .
  6. Add 3 <DynamicCodeBlockInput /> components with the following names: codeBlockReplace, codeBlockReplace2, codeBlockReplace3.
  7. Add a <DynamicCodeBlock /> with code and include the 3 replace variables within the code.
  8. Test that all the inputs work properly and correctly replace the variables in the code block with the text from the input.

Operating Systems Testing

n/a

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?

Related Issue

#440

Fixes #440

Added regex to find exact match when doing a replace all in the dynamic code block. This fixes issue when multiple inputs are used on a page and one input name or variable has no number but other inputs do have a number in the name attribute variable it doesn't break the find and replace functionality.
@alexaveldanez alexaveldanez self-assigned this Jun 17, 2025
@alexaveldanez alexaveldanez requested a review from st3phhays June 17, 2025 20:25
@st3phhays st3phhays merged commit b36f9b8 into chocolatey:main Jun 18, 2025
3 checks passed
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.

Allow for dynamic values to be injected into code blocks

2 participants