updated marked to v5; better baseurl handling

This commit is contained in:
2023-05-18 21:20:39 -07:00
parent e184b6f8b4
commit 95c15ee027
4 changed files with 35 additions and 28 deletions

11
src/base-url.ts Normal file
View File

@@ -0,0 +1,11 @@
import { marked } from 'marked';
import { MarkdownOptions } from './render';
export function base_url_walk_tokens(token: marked.Token, options: MarkdownOptions) {
if (options.base_url) {
if (token.type === 'link' || token.type === 'image') {
token.href = (new URL(token.href, options.base_url)).toString();
}
}
}