Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/jsx-email/src/renderer/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const processHtml = async (config: JsxEmailConfig, html: string) => {
let result = docType + String(doc).replace('<!doctype html>', '').replace('<head></head>', '');

result = result.replace(reJsxTags, '');
result = result.replace(/<jsx-email-raw.*?><!--(.*?)--><\/jsx-email-raw>/g, (_, p1) =>
result = result.replace(/<jsx-email-raw.*?><!--(.*?)--><\/jsx-email-raw>/gs, (_, p1) =>
unescapeForRawComponent(p1)
);

Expand Down
6 changes: 6 additions & 0 deletions packages/jsx-email/test/.snapshots/raw.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ exports[`<Raw> component > Should preserve content on plainText render 1`] = `"<

exports[`<Raw> component > Should render without escaping 1`] = `"<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\"><html><body><#if firstname & lastname>Ola!</#if></body></html>"`;

exports[`<Raw> component > Should work correctly when it has linebreaks 1`] = `
"<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\"><html><body>
Raw context
</body></html>"
`;

exports[`<Raw> component > Should work correctly with a comment as a content 1`] = `"<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\"><html><body><!--[if !mso]><!-->Ola!<!--<![endif]/--></body></html>"`;

exports[`<Raw> component > disablePlainTextOutput > Should not output to the plain text when enabled 1`] = `"Ola!"`;
Expand Down
13 changes: 13 additions & 0 deletions packages/jsx-email/test/raw.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ describe('<Raw> component', async () => {
expect(actual).toMatchSnapshot();
});

it('Should work correctly when it has linebreaks', async () => {
const actual = await render(
<>
<Raw
content={`
Raw context
`}
/>
</>
);
expect(actual).toMatchSnapshot();
});

describe('disablePlainTextOutput', () => {
it('Should not output to the plain text when enabled', async () => {
const actual = await render(
Expand Down
Loading