Skip to content

Commit 833fa0d

Browse files
committed
update to marked 13
1 parent 381823c commit 833fa0d

File tree

8 files changed

+46
-48
lines changed

8 files changed

+46
-48
lines changed

apps/svelte.dev/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"jimp": "^1.1.1",
7575
"lightningcss": "^1.25.1",
7676
"magic-string": "^0.30.11",
77-
"marked": "^12.0.2",
77+
"marked": "^13.0.3",
7878
"prettier": "^3.3.2",
7979
"prettier-plugin-svelte": "^3.2.4",
8080
"satori": "^0.10.13",

apps/svelte.dev/src/routes/content.json/+server.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ async function content() {
9191
}
9292

9393
async function plaintext(markdown: string) {
94-
const block = (text: unknown) => `${text}\n`;
94+
const block = ({ text }: any) => `${text}\n`;
9595

96-
const inline = (text: string) => text;
96+
const inline = ({ text }: any) => text;
9797

9898
return (
9999
await markedTransform(markdown, {
100-
code: (source) => source.split('// ---cut---\n').pop() || 'ERROR: ---cut--- not found',
100+
code: ({ text }) => text.split('// ---cut---\n').pop() || 'ERROR: ---cut--- not found',
101101
blockquote: block,
102102
html: () => '\n',
103103
heading: (text) => `${text}\n`,
@@ -108,16 +108,16 @@ async function plaintext(markdown: string) {
108108
paragraph: (text) => `${text}\n\n`,
109109
table: block,
110110
tablerow: block,
111-
tablecell: (text, opts) => {
111+
tablecell: ({ text }) => {
112112
return text + ' ';
113113
},
114114
strong: inline,
115115
em: inline,
116116
codespan: inline,
117117
br: () => '',
118118
del: inline,
119-
link: (href, title, text) => text,
120-
image: (href, title, text) => text,
119+
link: inline,
120+
image: inline,
121121
text: inline
122122
})
123123
)

apps/svelte.dev/src/routes/tutorial/[slug]/markdown.server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const default_renderer = {
115115
*/
116116
export async function transform(markdown, options) {
117117
const marked = new Marked({
118+
useNewRenderer: true,
118119
renderer: {
119120
...default_renderer,
120121
...options

packages/repl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"acorn": "^8.11.3",
7979
"esm-env": "^1.0.0",
8080
"esrap": "^1.2.2",
81-
"marked": "^11.2.0",
81+
"marked": "^13.0.3",
8282
"resolve.exports": "^2.0.2",
8383
"svelte": "^5.0.0-next.243",
8484
"zimmerframe": "^1.1.2"

packages/site-kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@types/node": "^20.12.11",
3535
"flexsearch": "^0.7.43",
3636
"magic-string": "^0.30.11",
37-
"marked": "^12.0.2",
37+
"marked": "^13.0.3",
3838
"prettier": "^3.3.2",
3939
"prettier-plugin-svelte": "^3.2.4",
4040
"shiki-twoslash": "^3.1.2",

packages/site-kit/src/lib/markdown/renderer.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -259,42 +259,40 @@ async function parse({
259259
// from linking to themselves
260260
let current = '';
261261

262-
/** @type {string} */
263-
const content = await transform(body, {
264-
text: smart_quotes,
265-
heading(html, level, raw) {
266-
const title = html
262+
return await transform(body, {
263+
text({ text }) {
264+
return smart_quotes(text);
265+
},
266+
heading({ text, depth, raw }) {
267+
const title = text
267268
.replace(/<\/?code>/g, '')
268269
.replace(/&quot;/g, '"')
269270
.replace(/&lt;/g, '<')
270271
.replace(/&gt;/g, '>');
271-
272272
current = title;
273-
274273
const normalized = normalizeSlugify(raw);
275-
276-
headings[level - 1] = normalized;
277-
headings.length = level;
278-
274+
headings[depth - 1] = normalized;
275+
headings.length = depth;
279276
const slug = headings.filter(Boolean).join('-');
280-
281-
return `<h${level} id="${slug}">${html.replace(
277+
return `<h${depth} id="${slug}">${text.replace(
282278
/<\/?code>/g,
283279
''
284-
)}<a href="#${slug}" class="permalink"><span class="visually-hidden">permalink</span></a></h${level}>`;
280+
)}<a href="#${slug}" class="permalink"><span class="visually-hidden">permalink</span></a></h${depth}>`;
285281
},
286-
code: (source, language) => code(source, language ?? 'js', current),
287-
codespan,
288-
blockquote: (content) => {
282+
code({ text, lang }) {
283+
return code(text, lang ?? 'js', current);
284+
},
285+
codespan({ text }) {
286+
return codespan(text);
287+
},
288+
blockquote(token) {
289+
let content = this.parser?.parse(token.tokens) ?? '';
289290
if (content.includes('[!LEGACY]')) {
290291
content = `<details class="legacy"><summary>Legacy mode</summary>${content.replace('[!LEGACY]', '')}</details>`;
291292
}
292-
293293
return `<blockquote>${content}</blockquote>`;
294294
}
295295
});
296-
297-
return content;
298296
}
299297

300298
/**

packages/site-kit/src/lib/markdown/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const tokenizer: TokenizerObject = {
105105

106106
export async function transform(markdown: string, renderer: Partial<Renderer> = {}) {
107107
const marked = new Marked({
108+
useNewRenderer: true,
108109
renderer,
109110
tokenizer
110111
});

pnpm-lock.yaml

Lines changed: 17 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)