JSPM

@mfyz/markdown-renderer-with-custom-directives

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q47952F
  • License MIT

Zero-dependency markdown renderer with custom directives

Package Exports

  • @mfyz/markdown-renderer-with-custom-directives
  • @mfyz/markdown-renderer-with-custom-directives/dist/index.browser.js
  • @mfyz/markdown-renderer-with-custom-directives/dist/index.cjs.js
  • @mfyz/markdown-renderer-with-custom-directives/dist/index.esm.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mfyz/markdown-renderer-with-custom-directives) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@mfyz/markdown-renderer-with-custom-directives

A zero-dependency markdown renderer with support for custom directives. This package is part of the @mfyz/markdown-editor-with-custom-directives project.

Features

  • Zero dependencies
  • Support for basic markdown syntax (bold, italic, strikethrough, links)
  • Custom directives:
    • Color directive (:color[text]{#color})
    • Button directive (:button[text]{url=URL shape=SHAPE color=COLOR})
  • Multiple distribution formats (ESM, CommonJS, IIFE)
  • Tiny bundle size
  • Browser and Node.js support

Installation

npm install @mfyz/markdown-renderer-with-custom-directives

Usage

ES Modules

import { render } from '@mfyz/markdown-renderer-with-custom-directives'

const markdown =
  '**Bold** and :color[colored]{#ff0000} with :button[Click me]{url=https://example.com shape=pill color=blue}'
const html = render(markdown)

CommonJS

const { render } = require('@mfyz/markdown-renderer-with-custom-directives')

const markdown =
  '**Bold** and :color[colored]{#ff0000} with :button[Click me]{url=https://example.com shape=pill color=blue}'
const html = render(markdown)

Browser

<script src="https://unpkg.com/@mfyz/markdown-renderer-with-custom-directives/dist/index.browser.js"></script>
<script>
  const markdown =
    '**Bold** and :color[colored]{#ff0000} with :button[Click me]{url=https://example.com shape=pill color=blue}'
  const html = MarkdownRenderer.render(markdown)
</script>

Custom Directives

Color Directive

The color directive allows you to add colored text:

:color[This text will be red]{#ff0000}

Button Directive

The button directive creates styled buttons with various presets:

:button[Click me]{url=https://example.com shape=pill color=blue}

Available button styles:

  • Shapes: pill, rounded, rect
  • Colors: blue, purple, green, red, yellow, gray

Example variations:

:button[Primary]{url=https://example.com shape=pill color=blue}
:button[Success]{url=https://example.com shape=rect color=green}
:button[Warning]{url=https://example.com shape=rounded color=yellow}

API Reference

render(markdown: string): string

Renders markdown text with custom directives into HTML.

Parameters:

  • markdown: The markdown text to render

Returns:

  • HTML string with rendered markdown and custom directives

Development

# Install dependencies
npm install

# Run tests
npm test

# Build distribution files
npm run build

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

License

MIT License - see the LICENSE file for details.