0.1.2 • Published 1 year ago

markdown-it-link-to-html v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

markdown-it-link-to-html

Link conversion to HTML

[me](https://me.me)

<a href="https://me.me">me</a> into <RouterLink to="https://me.me">me</RouterLink>

Install

npm i -D markdown-it-link-to-html

Usage

  1. For HTTPS,Change to ReplaceLink
import MarkdownIt from "markdown-it";
import LinkToHtml from "markdown-it-link-to-html";

const md = MarkdownIt();

md.use(LinkToHtml, {
    replaceLink: (href) => {
        if (href.startsWith("https")) {
            /// href is https, return ReplaceLink
            return {
                tag: "ReplaceLink",
            };
        }
        /// href is no https, don't change
        return undefined;
    },
});
  1. All change to RouterLink
import MarkdownIt from "markdown-it";
import LinkToHtml from "markdown-it-link-to-html";

const md = MarkdownIt();

md.use(LinkToHtml, {
    replaceLink: (href) => {
        return {
            tag: "RouterLink",
            hrefName: "to",
        };
    },
});
import MarkdownIt from "markdown-it";
import LinkToHtml from "markdown-it-link-to-html";

const md = MarkdownIt();

md.use(LinkToHtml, {
    linkify: true, // To deal AutoLink
    replaceLink: (href) => {
        return {
            tag: "RouterLink", // Modify RouterLink to tag,Required.
            hrefName: "to", // Modify href key to to
            href: "/", //  Modify href value to /
            title: "hi", //  Modify title value to hi
            // Add attribute,But the key can't be href or title
            attrs: { 
                class: "p1"
            }
        };
    },
});

MIT License

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago