marked-base-url
v1.1.6
Published
marked base url
Downloads
6,177
Readme
marked-base-url
Prefix relative url with base url.
Usage
// ESM
import {marked} from "marked";
import {baseUrl} from "marked-base-url";
marked.use(baseUrl("https://example.com/folder/"));
const html = marked.parse("[my url](./relative/path)");
// <p><a href="https://example.com/folder/relative/path">my url</a></p>
// BROWSER
<script src="https://cdn.jsdelivr.net/npm/marked"></script>
<script src="https://cdn.jsdelivr.net/npm/marked-base-url"></script>
<script>
marked.use(markedBaseUrl.baseUrl("https://example.com/folder/"));
const html = marked.parse("[my url](./relative/path)");
// <p><a href="https://example.com/folder/relative/path">my url</a></p>
</script>