feat: rework content handling to support inline markdown

This commit is contained in:
Anthony Fu 2022-11-30 13:27:24 +08:00
parent ccf6a17f72
commit db5a022f3b
6 changed files with 216 additions and 30 deletions

View file

@ -1,20 +1,27 @@
// Vitest Snapshot v1
exports[`content-rich > code frame 1`] = `
"<p>Testing code block</p><p><pre lang=\\"ts\\">import { useMouse, usePreferredDark } from &#39;@vueuse/core&#39;
"<p>Testing code block</p>
<p></p>
<pre lang=\\"ts\\">
import { useMouse, usePreferredDark } from &#39;@vueuse/core&#39;
// tracks mouse position
const { x, y } = useMouse()
// is the user prefers dark theme
const isDark = usePreferredDark()</pre></p>"
const isDark = usePreferredDark()</pre
>
<p></p>
"
`;
exports[`content-rich > code frame 2 1`] = `
"<p>
<span class=\\"h-card\\"><a class=\\"u-url mention\\" to=\\"/@antfu@mas.to\\"></a></span>
Testing<br />
<pre lang=\\"ts\\">const a = hello</pre>
</p>
<pre lang=\\"ts\\">const a = hello</pre>
<p></p>
"
`;

View file

@ -0,0 +1,73 @@
// Vitest Snapshot v1
exports[`html-parse > code frame 1`] = `
"<p>Testing code block</p>
<p></p>
<pre><code class=\\"language-ts\\">import { useMouse, usePreferredDark } from '@vueuse/core'
// tracks mouse position
const { x, y } = useMouse()
// is the user prefers dark theme
const isDark = usePreferredDark()</code></pre>
<p></p>
"
`;
exports[`html-parse > code frame 2 1`] = `
"<p>
<span class=\\"h-card\\"
><a href=\\"https://mas.to/@antfu\\" class=\\"u-url mention\\"
>@<span>antfu</span></a
></span
>
Testing<br />
</p>
<pre><code class=\\"language-ts\\">const a = hello</code></pre>
<p></p>
"
`;
exports[`html-parse > custom emoji 1`] = `
"Daniel Roe
<img
src=\\"https://media.mas.to/masto-public/cache/custom_emojis/images/000/288/667/original/c96ba3cb0e0e1eac.png\\"
alt=\\":nuxt:\\"
class=\\"custom-emoji\\"
/>
"
`;
exports[`html-parse > empty 1`] = `""`;
exports[`html-parse > inline markdown 1`] = `
"<p>text <code>code</code> <b>bold</b> <em>italic</em></p>
<p></p>
<pre><code class=\\"language-js\\">code block</code></pre>
<p></p>
"
`;
exports[`html-parse > link + mention 1`] = `
"<p>
Happy 🤗 were now using
<span class=\\"h-card\\"
><a
href=\\"https://mas.to/@vitest\\"
class=\\"u-url mention\\"
rel=\\"nofollow noopener noreferrer\\"
target=\\"_blank\\"
>@<span>vitest</span></a
></span
>
(migrated from chai+mocha)
<a
href=\\"https://github.com/ayoayco/astro-reactive-library/pull/203\\"
rel=\\"nofollow noopener noreferrer\\"
target=\\"_blank\\"
><span class=\\"invisible\\">https://</span
><span class=\\"ellipsis\\">github.com/ayoayco/astro-react</span
><span class=\\"invisible\\">ive-library/pull/203</span></a
>
</p>
"
`;