marked-base-url

markedjs
esm cjs
marked-base-url JS library on GitHub marked-base-url JS library on npm Download marked-base-url JS library

marked base url

Version 1.1.6 License MIT Vulnerabilities 0
marked-base-url has no homepage
marked-base-url JS library on GitHub
marked-base-url JS library on npm
Download marked-base-url JS library
Keywords
markedextensionbaseurl

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>