Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
marked-terminal
Advanced tools
The marked-terminal package is a custom renderer for the marked library, allowing Markdown content to be rendered in the terminal. It converts Markdown into ANSI escape codes to display styled text and other elements directly in the command line interface. This is particularly useful for CLI applications that want to display rich text content or documentation in a more readable and visually appealing format.
Rendering Headers
This feature allows the rendering of Markdown headers in the terminal with appropriate styling to distinguish them from other text.
const TerminalRenderer = require('marked-terminal');
const marked = require('marked');
marked.setOptions({
renderer: new TerminalRenderer()
});
console.log(marked('# Header 1'));
// This will output a styled Header 1 in the terminal
Rendering Links
This feature enables the display of clickable links in the terminal, making it easier to reference web resources directly from the command line output.
const TerminalRenderer = require('marked-terminal');
const marked = require('marked');
marked.setOptions({
renderer: new TerminalRenderer()
});
console.log(marked('[GitHub](https://github.com)'));
// This will output the text 'GitHub' as a clickable link in the terminal, if supported, or display the URL next to the text.
Rendering Lists
This feature supports the rendering of bullet and numbered lists, enhancing the readability of list information in the terminal.
const TerminalRenderer = require('marked-terminal');
const marked = require('marked');
marked.setOptions({
renderer: new TerminalRenderer()
});
console.log(marked('- Item 1\n- Item 2'));
// This will output a styled list with 'Item 1' and 'Item 2' as its elements.
Chalk is a popular npm package for styling terminal text with ANSI colors but does not directly support Markdown. Unlike marked-terminal, users need to manually specify styles for each piece of text.
ansi-styles allows for styling terminal output with ANSI escape codes. It provides lower-level access to styling compared to marked-terminal, which abstracts Markdown rendering into styled terminal output.
cli-md is a tool similar to marked-terminal that renders Markdown files in the terminal. It focuses on converting Markdown files to terminal output, similar to marked-terminal, but may have different rendering options and styles.
Custom Renderer for marked allowing for printing Markdown to the Terminal. Supports pretty tables, syntax highlighting for javascript, and overriding all colors and styles.
Could for instance be used to print usage information.
npm install marked marked-terminal
var marked = require('marked');
var TerminalRenderer = require('../');
marked.setOptions({
// Define custom renderer
renderer: new TerminalRenderer()
});
// Show the parsed data
console.log(marked('# Hello \n This is **markdown** printed in the `terminal`'));
This will produce the following:
Also have support for syntax highlighting using cardinal.
You can override highlight defaults by passing in settings as the second argument for TerminalRenderer,
or you can create a .cardinalrc
as defined in the cardinal README.
Example source
``js
var foo = function(bar) {
console.log(bar);
};
foo('Hello');
``
(But with proper syntax. Using "``" to avoid Github markdown)
// Show the parsed data
console.log(marked(exampleSource));
This will produce the following:
Constructur: new TerminalRenderer([options][, highlightOptions])
options
Optional Used to override default styling.
Default values are:
var defaultOptions = {
// Colors
code: chalk.yellow,
blockquote: chalk.gray.italic,
html: chalk.gray,
heading: chalk.green.bold,
firstHeading: chalk.magenta.underline.bold,
hr: chalk.reset,
listitem: chalk.reset,
table: chalk.reset,
paragraph: chalk.reset,
strong: chalk.bold,
em: chalk.italic,
codespan: chalk.yellow,
del: chalk.dim.gray.strikethrough,
link: chalk.blue,
href: chalk.blue.underline,
// Reflow and print-out width
width: 80, // only applicable when reflow is true
reflowText: false,
// Should it prefix headers?
showSectionPrefix: true,
// Wheter or not to undo marked escaping
// of enitities (" -> " etc)
unescape: true,
// Whether or not to show emojis
emoji: true,
// Options passed to cli-table
tableOptions: {}
};
marked.setOptions({
renderer: new TerminalRenderer({
codespan: chalk.underline.magenta,
})
});
highlightOptions
Options passed into cardinal. See readme there to see what options to pass.
See more examples
FAQs
A custom render for marked to output to the Terminal
The npm package marked-terminal receives a total of 964,417 weekly downloads. As such, marked-terminal popularity was classified as popular.
We found that marked-terminal demonstrated a healthy version release cadence and project activity because the last version was released less than 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.