diff --git a/app/composables/content-parse.ts b/app/composables/content-parse.ts index 3f749e74..f73be5ba 100644 --- a/app/composables/content-parse.ts +++ b/app/composables/content-parse.ts @@ -104,11 +104,12 @@ export function parseMastodonHTML( .replace(//g, '>') .replace(/`/g, '`') + .replace(/\*/g, '*') const classes = lang ? ` class="language-${lang}"` : '' return `>
${code}
` }) .replace(/`([^`\n]*)`/g, (_1, raw) => { - return raw ? `${htmlToText(raw).replace(//g, '>')}` : '' + return raw ? `${htmlToText(raw).replace(//g, '>').replace(/\*/g, '*')}` : '' }) } diff --git a/tests/nuxt/__snapshots__/content-rich.test.ts.snap b/tests/nuxt/__snapshots__/content-rich.test.ts.snap index 4e99489c..645c08ba 100644 --- a/tests/nuxt/__snapshots__/content-rich.test.ts.snap +++ b/tests/nuxt/__snapshots__/content-rich.test.ts.snap @@ -1,5 +1,12 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +exports[`content-rich > asterisk paris in code block 1`] = `"

1 * 2 * 3

"`; + +exports[`content-rich > asterisk paris in inline code 1`] = ` +"

1 * 2 * 3

+" +`; + exports[`content-rich > block with backticks 1`] = `"

[(\`number string) (\`tag string)]

"`; exports[`content-rich > block with injected html, with a known language 1`] = ` diff --git a/tests/nuxt/content-rich.test.ts b/tests/nuxt/content-rich.test.ts index e1eb2d9b..3eb7982f 100644 --- a/tests/nuxt/content-rich.test.ts +++ b/tests/nuxt/content-rich.test.ts @@ -186,6 +186,16 @@ describe('content-rich', () => { `) expect(formatted).toMatchSnapshot() }) + + it ('asterisk paris in inline code', async () => { + const { formatted } = await render('

`1 * 2 * 3`

') + expect(formatted).toMatchSnapshot() + }) + + it ('asterisk paris in code block', async () => { + const { formatted } = await render('

```
1 * 2 * 3
```

') + expect(formatted).toMatchSnapshot() + }) }) describe('editor', () => {