Repository: remarkablemark/html-react-parser (ts)

Issue:
Any text with \r (including with an escaped \) is removed by parser
## Expected Behavior

In a text document use of an escaped backslash before an r character should not remove the r character. This is necessary for eg. latex, where commands like \right) are common. 

## Actual Behavior

All \r are removed from the html document, even if the raw string is formatted as "\\r".

This seems to have been caused by the fix to #864 

## Steps to Reproduce

Create a html document with \\r inside the html string, run it through the html parser.

## Reproducible Demo

https://stackblitz.com/edit/html-react-parser-typescript-w9j4u9vu?file=src%2Findex.tsx
<!--
Creating a bug demo will help speed up the process of resolving the issue:

* StackBlitz: https://stackblitz.com/edit/html-react-parser
* TypeScript: https://stackblitz.com/edit/html-react-parser-typescript
* JSFiddle: https://jsfiddle.net/remarkablemark/7v86d800/
* Replit: https://replit.com/@remarkablemark/html-react-parser
-->

## Environment

- Version: 5.2.0
- Browser: Chrome
- OS: Macos

## Keywords

<!-- Include keywords that might help others with the same problem find this issue. -->


Pull request description:
fix(package): bump html-dom-parser to 5.0.12 so that `\\r` isn't escaped
Fixes #1634

Bumps [html-dom-parser](https://github.com/remarkablemark/html-dom-parser) from 5.0.11 to 5.0.12.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/remarkablemark/html-dom-parser/releases">html-dom-parser's releases</a>.</em></p>
<blockquote>
<h2>v5.0.12</h2>
<h2><a href="https://github.com/remarkablemark/html-dom-parser/compare/v5.0.11...v5.0.12">5.0.12</a> (2024-12-16)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>client:</strong> don't break LaTeX when replacing carriage returns (<a href="https://github.com/remarkablemark/html-dom-parser/commit/d69bc662f4470cd8ebf551af873cd7badfa6ebca">d69bc66</a>), closes <a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/917">#917</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/remarkablemark/html-dom-parser/blob/master/CHANGELOG.md">html-dom-parser's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/remarkablemark/html-dom-parser/compare/v5.0.11...v5.0.12">5.0.12</a> (2024-12-16)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>client:</strong> don't break LaTeX when replacing carriage returns (<a href="https://github.com/remarkablemark/html-dom-parser/commit/d69bc662f4470cd8ebf551af873cd7badfa6ebca">d69bc66</a>), closes <a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/917">#917</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/882a899cebd7a062771f199a0a5792b1484a4087"><code>882a899</code></a> Merge pull request <a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/924">#924</a> from remarkablemark/release-please--branches--master-...</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/05c42f5dbf1d714a7a3a2e33b5e1d1497301f771"><code>05c42f5</code></a> build(package): bump <code>@​rollup/plugin-typescript</code> from 12.1.1 to 12.1.2</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/92f3c7ff8a55c0d2cdf1a41858d206d062c919f3"><code>92f3c7f</code></a> chore(master): release 5.0.12</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/6c7ac1d0d50a5c02e90de31a839f0034554e0c75"><code>6c7ac1d</code></a> Merge pull request <a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/923">#923</a> from remarkablemark/fix/utilities</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/bcda37e015e10abb4cd5c715dfd0c5225a52576c"><code>bcda37e</code></a> build(deps-dev): bump <code>@​rollup/plugin-commonjs</code> from 28.0.1 to 28.0.2 (<a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/921">#921</a>)</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/e705fb284284fa823b68a96711f8cdbe625b9a5e"><code>e705fb2</code></a> build(deps-dev): bump <code>@​eslint/js</code> in the eslint group (<a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/919">#919</a>)</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/34e04a83a24c21c9bfa50d414a2a0e4d29529ebd"><code>34e04a8</code></a> build(deps-dev): bump <code>@​rollup/plugin-node-resolve</code> from 15.3.0 to 16.0.0 (<a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/920">#920</a>)</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/51d04bf46f80bcf2a29dc6307137e416d2683500"><code>51d04bf</code></a> build(deps-dev): bump eslint from 9.16.0 to 9.17.0 (<a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/922">#922</a>)</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/89bf0a6a818d3f4a4ad56d97cbf5237d026531c6"><code>89bf0a6</code></a> build(deps-dev): bump <code>@​commitlint/cli</code> in the commitlint group (<a href="https://redirect.github.com/remarkablemark/html-dom-parser/issues/918">#918</a>)</li>
<li><a href="https://github.com/remarkablemark/html-dom-parser/commit/d69bc662f4470cd8ebf551af873cd7badfa6ebca"><code>d69bc66</code></a> fix(client): don't break LaTeX when replacing carriage returns</li>
<li>Additional commits viewable in <a href="https://github.com/remarkablemark/html-dom-parser/compare/v5.0.11...v5.0.12">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=html-dom-parser&package-manager=npm_and_yarn&previous-version=5.0.11&new-version=5.0.12)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Patch:
diff --git a/package-lock.json b/package-lock.json
index f8d73f7..522504f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,7 @@
       "license": "MIT",
       "dependencies": {
         "domhandler": "5.0.3",
-        "html-dom-parser": "5.0.11",
+        "html-dom-parser": "5.0.12",
         "react-property": "2.0.2",
         "style-to-js": "1.1.16"
       },
@@ -5461,10 +5461,9 @@
       }
     },
     "node_modules/html-dom-parser": {
-      "version": "5.0.11",
-      "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-5.0.11.tgz",
-      "integrity": "sha512-iORudm2K0c0DYeEj4AbrG9PFzgp1dpFGkJUAiBlVTkeyaNf2YYIs1b0dF7rQUPnDZimkLx+Jls+CvRIKO/++Tg==",
-      "license": "MIT",
+      "version": "5.0.12",
+      "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-5.0.12.tgz",
+      "integrity": "sha512-LP2BI8aCnv6HCnO1kyQMaycqL7RCTUODGFWdKwrlc6ROG5rtbVEtE4mkBn1tokBMflUN7wyNKL4AXq7EMmga6Q==",
       "dependencies": {
         "domhandler": "5.0.3",
         "htmlparser2": "9.1.0"
diff --git a/package.json b/package.json
index 52ed47d..5c85d2d 100644
--- a/package.json
+++ b/package.json
@@ -49,7 +49,7 @@
   ],
   "dependencies": {
     "domhandler": "5.0.3",
-    "html-dom-parser": "5.0.11",
+    "html-dom-parser": "5.0.12",
     "react-property": "2.0.2",
     "style-to-js": "1.1.16"
   },


Test patch:
diff --git a/__tests__/__snapshots__/dom-to-react.test.tsx.snap b/__tests__/__snapshots__/dom-to-react.test.tsx.snap
index 84219b0..f4d27a5 100644
--- a/__tests__/__snapshots__/dom-to-react.test.tsx.snap
+++ b/__tests__/__snapshots__/dom-to-react.test.tsx.snap
@@ -6,6 +6,18 @@ exports[`domToReact converts <textarea> correctly 1`] = `
 />
 `;
 
+exports[`domToReact converts LaTeX 1`] = `
+[
+  <span
+    className="math"
+  >
+    \\left(\\right)\\rD\\rightarrow\\reals\\ni
+  </span>,
+  "
+",
+]
+`;
+
 exports[`domToReact converts SVG element with viewBox attribute 1`] = `
 <svg
   id="foo"
diff --git a/__tests__/data/html.ts b/__tests__/data/html.ts
index 4d4027c..7c7da6f 100644
--- a/__tests__/data/html.ts
+++ b/__tests__/data/html.ts
@@ -19,4 +19,6 @@ export const html = {
   form: '<input type="text" value="foo" checked="checked">',
   list: '<ol><li>One</li><li value="2">Two</li></ol>',
   template: '<template><article><p>Test</p></article></template>',
+  latex:
+    '<span class="math">\\left(\\right)\\rD\\rightarrow\\reals\\ni</span>\r\n',
 } as const;
diff --git a/__tests__/dom-to-react.test.tsx b/__tests__/dom-to-react.test.tsx
index b3f3bfb..40b28bc 100644
--- a/__tests__/dom-to-react.test.tsx
+++ b/__tests__/dom-to-react.test.tsx
@@ -56,9 +56,8 @@ describe('domToReact', () => {
   });
 
   it('does not throw an error for void elements', () => {
-    const reactElements = domToReact(htmlToDOM(html.void));
     expect(() => {
-      render(<div>{reactElements}</div>);
+      render(<div>{domToReact(htmlToDOM(html.void))}</div>);
     }).not.toThrow();
   });
 
@@ -80,8 +79,11 @@ describe('domToReact', () => {
   });
 
   it('converts custom element with attributes', () => {
-    const reactElement = domToReact(htmlToDOM(html.customElement));
-    expect(reactElement).toMatchSnapshot();
+    expect(domToReact(htmlToDOM(html.customElement))).toMatchSnapshot();
+  });
+
+  it('converts LaTeX', () => {
+    expect(domToReact(htmlToDOM(html.latex))).toMatchSnapshot();
   });
 });
 
@@ -104,7 +106,7 @@ describe('library option', () => {
     expect(React.isValidElement(parsedElement)).toBe(false);
     expect(Preact.isValidElement(parsedElement)).toBe(true);
     // remove `__v` key since it's causing test equality to fail
-    // @ts-expect-error Property '__v' does not exist on type '...roperty '__v' does not exist on type 'string'.
+    // @ts-expect-error Property '__v' does not exist on type 'string'.
     delete parsedElement.__v;
     delete preactElement.__v;
     expect(parsedElement).toEqual(preactElement);