Skip to content

Commit 365795f

Browse files
committed
feat: removed data-id attr from markup
1 parent cefbc43 commit 365795f

File tree

5 files changed

+24
-40
lines changed

5 files changed

+24
-40
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
### [2.0.2](https://github.com/codeskills-dev/md-to-react-email/compare/v2.0.1...v2.0.2) (2023-06-20)
7+
8+
### Features
9+
10+
- Removed `data-id` attributes from markup
11+
612
### [2.0.1](https://github.com/codeskills-dev/md-to-react-email/compare/v1.2.0...v2.0.1) (2023-06-20)
713

814
### Features

__tests__/parseMarkdownToReactEmailJSX.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
describe("Markdown to React Mail JSX Parser", () => {
88
it("converts header one correctly", () => {
99
const markdown = "# Hello, World!";
10-
const expected = `<h1 data-id="react-email-heading" style="${parseCssInJsToInlineCss(
10+
const expected = `<h1 style="${parseCssInJsToInlineCss(
1111
styles.h1
1212
)}">Hello, World!</h1>`;
1313

@@ -27,7 +27,7 @@ describe("Markdown to React Mail JSX Parser", () => {
2727

2828
it("converts links correctly", () => {
2929
const markdown = "[Codeskills](https://codeskills.dev)";
30-
const expected = `<a data-id=\"react-email-link\" target=\"_blank\" href="https://codeskills.dev" style="${parseCssInJsToInlineCss(
30+
const expected = `<a target=\"_blank\" href="https://codeskills.dev" style="${parseCssInJsToInlineCss(
3131
styles.link
3232
)}">Codeskills</a>`;
3333

@@ -39,7 +39,7 @@ describe("Markdown to React Mail JSX Parser", () => {
3939
const markdown = '```javascript\nconsole.log("Hello, World!");\n```';
4040
const expected = `<pre style="${parseCssInJsToInlineCss(
4141
styles.codeBlock
42-
)}"><p data-id="react-email-text">{\`javascript
42+
)}"><p>{\`javascript
4343
console.log("Hello, World!");
4444
\`}</p></pre>`;
4545

__tests__/reactEmailMarkdown.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("ReactEmailMarkdown component renders correctly", () => {
88
<ReactEmailMarkdown markdown={`# Hello, World!`} />
99
);
1010
expect(actualOutput).toMatchInlineSnapshot(
11-
`"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><div><h1 data-id="react-email-heading" style="font-weight:500;padding-top:20;font-size:2.5rem">Hello, World!</h1></div>"`
11+
`"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><div><h1 style="font-weight:500;padding-top:20;font-size:2.5rem">Hello, World!</h1></div>"`
1212
);
1313
});
1414
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "md-to-react-email",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A simple Markdown parser for React-email written in typescript.",
55
"keywords": [
66
"markdown",

src/utils.ts

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -198,39 +198,27 @@ export function parseMarkdownToReactEmailJSX(
198198
// Handle headings (e.g., # Heading)
199199
reactMailTemplate = markdown.replace(
200200
patterns.h1,
201-
`<h1 data-id="react-email-heading" style="${parseCssInJsToInlineCss(
202-
finalStyles.h1
203-
)}">$1</h1>`
201+
`<h1 style="${parseCssInJsToInlineCss(finalStyles.h1)}">$1</h1>`
204202
);
205203
reactMailTemplate = reactMailTemplate.replace(
206204
patterns.h2,
207-
`<h2 data-id="react-email-heading" style="${parseCssInJsToInlineCss(
208-
finalStyles.h2
209-
)}">$1</h2>`
205+
`<h2 style="${parseCssInJsToInlineCss(finalStyles.h2)}">$1</h2>`
210206
);
211207
reactMailTemplate = reactMailTemplate.replace(
212208
patterns.h3,
213-
`<h3 data-id="react-email-heading" style="${parseCssInJsToInlineCss(
214-
finalStyles.h3
215-
)}">$1</h3>`
209+
`<h3 style="${parseCssInJsToInlineCss(finalStyles.h3)}">$1</h3>`
216210
);
217211
reactMailTemplate = reactMailTemplate.replace(
218212
patterns.h4,
219-
`<h4 data-id="react-email-heading" style="${parseCssInJsToInlineCss(
220-
finalStyles.h4
221-
)}">$1</h4>`
213+
`<h4 style="${parseCssInJsToInlineCss(finalStyles.h4)}">$1</h4>`
222214
);
223215
reactMailTemplate = reactMailTemplate.replace(
224216
patterns.h5,
225-
`<h5 data-id="react-email-heading" style="${parseCssInJsToInlineCss(
226-
finalStyles.h5
227-
)}">$1</h5>`
217+
`<h5 style="${parseCssInJsToInlineCss(finalStyles.h5)}">$1</h5>`
228218
);
229219
reactMailTemplate = reactMailTemplate.replace(
230220
patterns.h6,
231-
`<h6 data-id="react-email-heading" style="${parseCssInJsToInlineCss(
232-
finalStyles.h6
233-
)}">$1</h6>`
221+
`<h6 style="${parseCssInJsToInlineCss(finalStyles.h6)}">$1</h6>`
234222
);
235223

236224
// Handle Tables from GFM
@@ -303,17 +291,13 @@ export function parseMarkdownToReactEmailJSX(
303291
// Handle bold text (e.g., **bold**)
304292
reactMailTemplate = reactMailTemplate.replace(
305293
patterns.bold,
306-
`<p data-id="react-email-text" style="${parseCssInJsToInlineCss(
307-
finalStyles.bold
308-
)}">$1</p>`
294+
`<p style="${parseCssInJsToInlineCss(finalStyles.bold)}">$1</p>`
309295
);
310296

311297
// Handle italic text (e.g., *italic*)
312298
reactMailTemplate = reactMailTemplate.replace(
313299
patterns.italic,
314-
`<p data-id="react-email-text" style="${parseCssInJsToInlineCss(
315-
finalStyles.italic
316-
)}">$1</p>`
300+
`<p style="${parseCssInJsToInlineCss(finalStyles.italic)}">$1</p>`
317301
);
318302

319303
// Handle lists (unordered and ordered)
@@ -337,7 +321,7 @@ export function parseMarkdownToReactEmailJSX(
337321
// Handle links (e.g., [link text](url))
338322
reactMailTemplate = reactMailTemplate.replace(
339323
patterns.link,
340-
`<a data-id="react-email-link" target="_blank" href="$2" style="${parseCssInJsToInlineCss(
324+
`<a target="_blank" href="$2" style="${parseCssInJsToInlineCss(
341325
finalStyles.link
342326
)}">$1</a>`
343327
);
@@ -347,23 +331,19 @@ export function parseMarkdownToReactEmailJSX(
347331
patterns.codeBlocks,
348332
`<pre style="${parseCssInJsToInlineCss(
349333
finalStyles.codeBlock
350-
)}"><p data-id="react-email-text">${`{\`$1\`}`}</p></pre>`
334+
)}"><p>${`{\`$1\`}`}</p></pre>`
351335
);
352336

353337
// Handle inline code (e.g., `code`)
354338
reactMailTemplate = reactMailTemplate.replace(
355339
patterns.codeInline,
356-
`<p data-id="react-email-text" style="${parseCssInJsToInlineCss(
357-
finalStyles.codeInline
358-
)}">$1</p>`
340+
`<p style="${parseCssInJsToInlineCss(finalStyles.codeInline)}">$1</p>`
359341
);
360342

361343
// Handle block quotes
362344
reactMailTemplate = reactMailTemplate.replace(
363345
/^>\s+(.+)$/gm,
364-
`<p data-id="react-email-text" style="${parseCssInJsToInlineCss(
365-
finalStyles.blockQuote
366-
)}">$1</p>`
346+
`<p style="${parseCssInJsToInlineCss(finalStyles.blockQuote)}">$1</p>`
367347
);
368348

369349
// Handle line breaks (e.g., <br />)
@@ -375,9 +355,7 @@ export function parseMarkdownToReactEmailJSX(
375355
// Handle horizontal rules (e.g., ---)
376356
reactMailTemplate = reactMailTemplate.replace(
377357
patterns.hr,
378-
`<hr data-id="react-email-hr" style="${parseCssInJsToInlineCss(
379-
finalStyles.hr
380-
)}" />`
358+
`<hr style="${parseCssInJsToInlineCss(finalStyles.hr)}" />`
381359
);
382360

383361
return reactMailTemplate;

0 commit comments

Comments
 (0)