markdown-it-plugin-gitbook
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

markdown-it-plugin-gitbook

npm version License

📖 A markdown-it plugin for parsing GitBook-specific block tags

markdown-it-plugin-gitbook is a plugin for markdown-it that allows parsing GitBook-specific block tags. It currently supports the embed block.

Installation

Install via npm:

npm install markdown-it-plugin-gitbook

Or install via yarn:

yarn add markdown-it-plugin-gitbook

Usage

const markdownIt = require('markdown-it');
const markdownItGitBook = require('markdown-it-plugin-gitbook');

const md = markdownIt();
md.use(markdownItGitBook, {
   // embedUrls: { 'url': 'https://example.com/real/url' }
   embedUrls: (url) => {
      // Replace this to get real video player url instead of website url
      // This function does not support async call as markdown-it not support async
      return url
   }
});

const markdown = `Your GitBook content with embed blocks`;
const result = md.render(markdown);

console.log(result);

Block Tags

embed

The embed block tag allows you to embed various content such as videos, audios, or other web pages within GitBook.

{% embed url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" %}

Replace the url attribute with the URL of the content you want to embed.

We also support embed block tag with caption, like this

{% embed url="https://www.bilibili.com/video/BV1w24y1U7fx" %}
Abort fireboom
{% endembed %}

see more from test

Local Development

If you want to contribute or make modifications to the markdown-it-plugin-gitbook plugin, you can follow these steps for local development:

  1. Clone the repository:

    git clone https://github.com/your-username/markdown-it-plugin-gitbook.git
  2. Install dependencies:

We use bun to develop this plugin, so install bun first, then

cd markdown-it-plugin-gitbook
bun i
  1. Make your modifications and perform development.

  2. Run tests:

    bun test
  3. Commit your changes and create a Pull Request.

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i markdown-it-plugin-gitbook

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

43.5 kB

Total Files

12

Last publish

Collaborators

  • erguotou