Repository: ProjectEvergreen/greenwood (js)

Issue:
markdown rendering not correctly processing the text `$1`
## Type of Change
Bug

## Summary
If you have markdown with this content for the text _$10_, the _$1_ are getting stripped out.
```md
## Posters ($10)
```

![Screen Shot 2023-07-21 at 9 30 39 PM](https://github.com/ProjectEvergreen/greenwood/assets/895923/1237b9e8-b3a8-4890-91db-d67ede63df19)

```html
<h2>Posters (0)</h2>
```

## Details
Other examples like _$20_ and _$0_ work fine though.
https://github.com/AnalogStudiosRI/www.blissfestri.com/pull/124#issuecomment-1645589927

----

This seems very reminiscent of other `.replace` capture related bugs we've seen like so I bet it's that.
- https://github.com/ProjectEvergreen/greenwood/pull/743
- https://github.com/ProjectEvergreen/greenwood/pull/657

Seems like maybe we need to find a better way to do this kind of templating?  Seems a bit too naive / brittle considering how `.replace` works in conjunction with certain [replacement patterns](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement).  Probably good to start a discussion for that maybe?


Pull request description:
bug/issue 1126 handle string replace replacement patterns breaking markdown rendering when content has a $1 in it 
<!--
## Submitting a Pull Request
We love contributions and appreciate any help you can offer!
-->

## Related Issue
resolves #1126 

## Summary of Changes
1. handle string replace replacement patterns breaking markdown rendering when content has a _$1_ in it 
1. Add test case

----

Should probably at least open a discussion for this to find a better way to handle this, since it happens a lot in the codebase.
- https://github.com/ProjectEvergreen/greenwood/pull/743
- https://github.com/ProjectEvergreen/greenwood/pull/657

Patch:
diff --git a/packages/cli/src/plugins/resource/plugin-standard-html.js b/packages/cli/src/plugins/resource/plugin-standard-html.js
index 52fbd8e4..fd37aafd 100644
--- a/packages/cli/src/plugins/resource/plugin-standard-html.js
+++ b/packages/cli/src/plugins/resource/plugin-standard-html.js
@@ -182,7 +182,8 @@ class StandardHtmlResource extends ResourceInterface {
         });
       }
 
-      body = body.replace(/\<content-outlet>(.*)<\/content-outlet>/s, processedMarkdown.contents);
+      // https://github.com/ProjectEvergreen/greenwood/issues/1126
+      body = body.replace(/\<content-outlet>(.*)<\/content-outlet>/s, processedMarkdown.contents.replace(/\$/g, '$$$'));
     } else if (matchingRoute.external) {
       body = body.replace(/\<content-outlet>(.*)<\/content-outlet>/s, matchingRoute.body);
     } else if (ssrBody) {


Test patch:
diff --git a/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js b/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js
index 4798be2d..db607e99 100644
--- a/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js
+++ b/packages/cli/test/cases/build.default.markdown/build.default.markdown.spec.js
@@ -52,7 +52,15 @@ describe('Build Greenwood With: ', function() {
         dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html'));
       });
 
-      it('should correctly rendering an <h3> tag', function() {
+      // https://github.com/ProjectEvergreen/greenwood/issues/1126
+      it('should correctly render an <h2> tag with a $1 in the text content', function() {
+        const heading = dom.window.document.querySelectorAll('body h2');
+
+        expect(heading.length).to.equal(1);
+        expect(heading[0].textContent).to.equal('Posters $10');
+      });
+
+      it('should correctly render an <h3> tag', function() {
         const heading = dom.window.document.querySelectorAll('body h3');
 
         expect(heading.length).to.equal(1);
diff --git a/packages/cli/test/cases/build.default.markdown/src/pages/index.md b/packages/cli/test/cases/build.default.markdown/src/pages/index.md
index eb9d87ee..7fd6cb89 100644
--- a/packages/cli/test/cases/build.default.markdown/src/pages/index.md
+++ b/packages/cli/test/cases/build.default.markdown/src/pages/index.md
@@ -2,6 +2,8 @@
 title: 'this is a custom markdown title'
 ---
 
+## Posters $10
+
 ### Greenwood Markdown Test
 
 This is some markdown being rendered by Greenwood.