ts-markdown-builder
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

npm version Build npm bundle size PRs Welcome Star on GitHub

TS Markdown Builder

Elegant markdown builder with minimal bundle size.

Goal

TypeScript markdown generation library:

  • easy to read and write API
  • build CommonMark & GFM compliant markdown
  • minimal bundle size + tree-shakable

Installation

npm install ts-markdown-builder

Basic usage

import * as md from 'ts-markdown-builder';

const output = joinBlocks([
  md.heading('Welcome to TS Markdown Builder'),
  "It's an easy to use modern markdown generator.",
  'It supports:',
  md.list([
    `${md.bold('bold')} and ${md.italic('italic')}`,
    `${md.code('code')} spans and code blocks`,
    'unordered and ordered lists',
    'blockquotes',
    'and more!',
  ]),
]);
# Welcome to TS Markdown Builder

It's an easy to use modern markdown generator.

It supports:

- **bold** and _italic_
- \`code\` spans and code blocks
- unordered and ordered lists
- blockquotes
- and more!

Functions

Utils

  • joinBlocks(blocks: string[]) - join blocks of text into a single markdown document (string)

Block

  • heading(text: string, options?: { level: number = 1 })
  • blockquote(text: string | string[])
  • codeBlock(text: string)
  • list(items: string[])
  • orderedList(items: string[])
  • horizontalRule

Inline

  • bold(text: string)
  • italic(text: string)
  • code(text: string)
  • link(url: string, text?: string) - link or autolink
  • image(url: string, text?: string)
  • escape(text: string)

Table

  • table(headers: string[], rows: string[][])

HTML

  • disclosure(title: string, content: string, options?: { open?: boolean })
  • lineBreak

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Reference

TODO

Readme

Keywords

Package Sidebar

Install

npm i ts-markdown-builder

Weekly Downloads

19,101

Version

0.4.1

License

MIT

Unpacked Size

50.3 kB

Total Files

33

Last publish

Collaborators

  • mdjastrzebski