$ npm install omark
Just simple markdown utils!
[!NOTE] This project is under development and i am colleting more utils across my projects to here.
Install package:
# npm
npm install omark
# yarn
yarn add omark
# pnpm
pnpm install omark
# bun
bun install omark
Import:
// ESM
import { md } from "omark";
// CommonJS
const { md } = require("omark");
blockquote(text)Render a markdown blockquote text with > in front of a paragraph
Example:
md.blockquote('Hello, World!');
// => "> Hello, World!"
bold(text)Render a markdown bold text.
Example:
md.bold('Hello, World!');
// => "**Hello, World!**"
boldAndItalic(text)Render a markdown bold and italic text.
Example:
md.bold('Hello, World!');
// => "***Hello, World!***"
codeBlock(code, lang, opts)Format a string as a code block.
Example:
md.codeBlock('console.log("Hello, World!");', 'js');
// => "```js\nconsole.log("Hello, World!");\n```"
heading(text, level)Render a markdown heading.
Example:
md.heading(1, 'Hello, World!');
// => "\n# Hello, World!\n"
hr(length)Render a markdown horizontal rule.
Example:
md.hr();
// => "---"
image(url, text, opts)Render a markdown image.
Example:
md.image('https://cataas.com/cat', 'Cute Cat');
// => ""
italic(text)Render a markdown italic text.
Example:
md.bold('Hello, World!');
// => "_Hello, World!_"
link(url, text, opts)Render a markdown link.
Example:
md.link('Google', 'https://www.google.com');
// => "[Google](https://www.google.com)"
md.link('https://www.google.com', 'Google', { external: true });
// => "<a href="https://www.google.com" title="Google" target="_blank">Google</a>"
list(items, opts)Render a markdown ordered or unordered list.
Example:
md.list(['Item 1', 'Item 2', 'Item 3']);
// => "- Item 1\n- Item 2\n- Item 3"
strikethrough(text)Render a markdown strikethrough text.
Example:
md.strikethrough('Hello, World!');
// => "~~Hello, World!~~"
table(table)Render a markdown table.
Example:
md.table({
columns: ["Breed", "Origin", "Size", "Temperament"],
rows: [
["Abyssinian", "Egypt", "Medium", "Active"],
["Aegean", "Greece", "Medium", "Active"],
["American Bobtail", "United States", "Medium", "Active"],
["Applehead Siamese", "Thailand", "Medium", "Active"],
],
});
corepack enablepnpm installpnpm devMade with 💛
Published under MIT License.
© 2010 - cnpmjs.org x YWFE | Home | YWFE