updated marked to v5; better baseurl handling
This commit is contained in:
11
src/base-url.ts
Normal file
11
src/base-url.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user