JSPM

omark

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 55
  • Score
    100M100P100Q61453F
  • License MIT

Just simple markdown utils!

Package Exports

  • omark

Readme

⬇️ omark

npm version npm downloads

Just simple markdown utils!

[!NOTE] This project is under development and i am colleting more utils across my projects to here.

Usage

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");

Utils

Render

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');
// => "![Cute Cat](https://cataas.com/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"],
  ],
});

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.