easy-markdown
v1.0.2
Published
A simple and structured Markdown generator, makes easy to create markdowns and use them!
Readme
Markdown Generator
A simple and flexible JavaScript class to create Markdown content programmatically.
Supports headings, text styles (bold, italic, bold-italic, underline), code blocks, quotes, links, images, and checklists.
Features
- Create headings (H1, H2, H3) easily
- Format text as italic, bold, bold italic, or underline
- Insert fenced code blocks with optional language specification
- Add blockquotes
- Add links and images with alt text
- Create task/checklists with checkboxes
Installation
npm install easy-markdownUsage
const Markdown = require('easy-markdown');
const md = new Markdown();
md.setHeading(1, "Markdown Generator");
md.setHeadingDescription(1, "Generate Markdown content programmatically.");
md.italic("This text is italic");
md.bold("This text is bold");
md.boldItalic("This text is bold and italic");
md.__bold("This text is underlined bold");
md.setCodeBlock('console.log("Hello World");', "js");
md.setQuote("This is a blockquote.");
md.setLink("Youtube", "https://youtube.com");
md.setImage("Youtube logo", "https://upload.wikimedia.org/wikipedia/commons/thumb/0/09/YouTube_full-color_icon_%282017%29.svg/1024px-YouTube_full-color_icon_%282017%29.svg.png");
md.addChecklistItem("Write README", true);
md.addChecklistItem("Publish package", false);
console.log(md.get("heading1"));
console.log(md.renderChecklist());Docs
setHeading(number, text)— Set heading level 1, 2, or 3setHeadingDescription(number, text)— Add description text below headingitalic(text)— Italicize textbold(text)— Bold textboldItalic(text)— Bold and italic text__bold(text)— Underlined bold textsetCodeBlock(text, language)— Add fenced code blocksetQuote(text)— Add blockquotesetLink(label, url)— Add hyperlinksetImage(alt, url)— Add image with alt textaddChecklistItem(text, checked)— Add checklist item with checkboxrenderChecklist()— Render all checklist items as Markdown
