Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 700 Bytes

README.md

File metadata and controls

24 lines (19 loc) · 700 Bytes

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>