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
4 changes: 3 additions & 1 deletion src/components/Preheader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const fillerCount = computed(() =>

<template>
<Teleport to="body:start">
<div style="display: none">{{ text }}<template v-for="i in fillerCount" :key="i">&#8199;&#65279;&#847; </template>&nbsp;</div>
<div data-maizzle-html-only>
<div style="display: none">{{ text }}<template v-for="i in fillerCount" :key="i">&#8199;&#65279;&#847; </template>&nbsp;</div>
</div>
</Teleport>
</template>
2 changes: 1 addition & 1 deletion src/render/createRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ export async function createRenderer(
if (renderContext.preheader) {
const { text, fillerCount } = renderContext.preheader
const filler = '\u2007\uFEFF\u034F '.repeat(fillerCount)
const previewHtml = `<div style="display:none">${text}${filler}\u00A0</div>`
const previewHtml = `<div data-maizzle-html-only><div style="display:none">${text}${filler}\u00A0</div></div>`
html = html.replace(/<body([^>]*)>/, `<body$1>${previewHtml}`)
}

Expand Down
19 changes: 19 additions & 0 deletions src/tests/render/composables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,25 @@ describe('render', () => {
expect(result.plaintext).not.toContain('<div>')
})

it('excludes the preheader from plaintext', async () => {
const result = await render(`
<script setup>
usePreheader('From usePreheader')
</script>
<template>
<Layout>
<Preheader>From component</Preheader>
<p>Body</p>
</Layout>
</template>
`, { plaintext: true })

expect(result.plaintext).toBe('Body')
expect(result.html).toContain('From usePreheader')
expect(result.html).toContain('From component')
expect(result.html).not.toContain('data-maizzle-html-only')
})

it('passes strip options via plaintext.options', async () => {
const result = await render(`
<template>
Expand Down
Loading