@fsegurai/marked-extended-lists
v15.0.0
Published
Extended lists for Marked.js
Downloads
74
Readme
A library of extended lists for Marked.js.
@fsegurai/marked-extended-lists
is an extensions for Marked.js that adds support for extended lists. It allows you to
create lists with different types of markers and nested lists with different types of markers, like a.
, A.
, i.
,
I.
, and other patterns to be rendered as <ol>
elements with corresponding type
values (e.g., <ol type="a">
).
It also adds support for lists that start with a custom value or that skips values, by using the value
attribute on
the list item.
This enables more flexible list formatting in Markdown, enhancing the output to match the intended ordering style.
Table of contents
Installation
@fsegurai/marked-extended-lists
To add @fsegurai/marked-extended-lists
along with Marked.js to your package.json
use the following commands.
npm install @fsegurai/marked-extended-lists marked@^12.0.2 --save
Using Extended Lists
Import @fsegurai/marked-extended-lists
and apply it to your Marked instance as shown below.
import { marked } from "marked";
import markedExtendedLists from "@fsegurai/marked-extended-lists";
// or UMD script
// <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
// <script src="https://cdn.jsdelivr.net/npm/@fsegurai/marked-extended-lists/lib/index.umd.js"></script>
marked.use(markedExtendedLists());
const exampleMarkdown = `
1. item 1
2. item 2
a. item 2a
I. sub item I
II. sub item II
e. item 2e
7. item 7
`;
marked.parse(exampleMarkdown);
// <ol>
// <li>item 1</li>
// <li>item 2
// <ol type="a">
// <li>item 2a</li>
// <ol type="I">
// <li>sub item I</li>
// <li>sub item II</li>
// </ol>
// <li value="5">item 2e</li>
// </ol>
// </li>
// <li value="7">item 7</li>
// </ol>
Read the Marked.js documentation for more details about its usage.
Available Extensions
Demo Application
To see all themes in action, check out the demo: https://fsegurai.github.io/marked-extensions.
To set up the demo locally:
git clone https://github.com/fsegurai/marked-extensions.git
npm install
npm start
This will serve the application locally at http://[::1]:8000.
License
Licensed under MIT.