Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@types/marked
Advanced tools
@types/marked provides TypeScript type definitions for the 'marked' library, which is a fast, lightweight markdown parser and compiler. It allows developers to use 'marked' with TypeScript, ensuring type safety and better development experience.
Basic Markdown Parsing
This feature allows you to convert a markdown string into HTML. The code sample demonstrates how to use 'marked' to parse a simple markdown string and convert it to HTML.
const marked = require('marked');
const markdownString = '# Hello World';
const htmlString = marked(markdownString);
console.log(htmlString);
Custom Renderer
This feature allows you to customize the rendering of markdown elements. The code sample shows how to create a custom renderer that changes the color of headings to red.
const marked = require('marked');
const renderer = new marked.Renderer();
renderer.heading = function (text, level) {
return `<h${level} style="color: red;">${text}</h${level}>`;
};
const markdownString = '# Hello World';
const htmlString = marked(markdownString, { renderer: renderer });
console.log(htmlString);
Synchronous and Asynchronous Parsing
This feature allows you to parse markdown both synchronously and asynchronously. The code sample demonstrates both methods of parsing a markdown string.
const marked = require('marked');
const markdownString = '# Hello World';
// Synchronous
const htmlStringSync = marked(markdownString);
console.log(htmlStringSync);
// Asynchronous
marked(markdownString, (err, htmlStringAsync) => {
if (err) throw err;
console.log(htmlStringAsync);
});
Showdown is another markdown to HTML converter. It is similar to 'marked' in terms of functionality but offers additional features like extensions and more customization options. Showdown also has a TypeScript definition file available.
Markdown-it is a markdown parser that is designed to be pluggable and offers high performance. It provides more extensibility compared to 'marked' and has a rich plugin ecosystem. It also supports TypeScript through a separate type definition package.
Remark is a markdown processor powered by plugins. It is highly extensible and can be used to parse, transform, and compile markdown. Remark offers more flexibility and control over the markdown processing pipeline compared to 'marked'.
npm install --save @types/marked
This package contains type definitions for Marked (https://github.com/markedjs/marked).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/marked.
These definitions were written by William Orr, BendingBender, CrossR, Mike Wickett, Hitomi Hatsukaze, Ezra Celli, Romain LE BARO, Sarun Intaralawan, Tony Brix, and Anatolii Titov.
FAQs
Stub TypeScript definitions entry for marked, which provides its own types definitions
The npm package @types/marked receives a total of 531,894 weekly downloads. As such, @types/marked popularity was classified as popular.
We found that @types/marked demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.