0.0.1 • Published 2 years ago
remark-linkify-modifier v0.0.1
remark-linkify-modifier
Contents
What is this?
This package is a unified (remark) plugin to transform text to a link by regular expression with modifying. If you need linkify some text in your markdown by regular expression and do matches text some changes it's you choice. This package based on code of remark-linkify-regex but add modifying functionality.
Install
npm:
npm install remark-linkify-modifier
yarn:
yarn add remark-linkify-modifier
Use
import { unified } from "unified";
import remarkLinkifyModifier from "remark-linkify-modifier";
const file = await unified().use(
remarkLinkifyModifier({
regex: /github\.com\/?[^\s]*/,
modifier: {
modifyLink: (link) => "https://" + link,
},
})
);
console.log(String(file));
API
options
Configuration object or just a RegExp.
options.regex
RegExp for matches
👉 Note: you should define regex anyway.
options.modifier
Object for modify matches text (optional).
options.modifier.modifyText
/ options.modifier.modifyLink
Functions that modify matches text for link or text as you define
Types
This package is have declaration file for typescript.
License
0.0.1
2 years ago