Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
remove-markdown
Advanced tools
The remove-markdown npm package is a utility that strips Markdown formatting from text, leaving only the plain text content. This can be useful for displaying Markdown content in environments that do not support Markdown or for preprocessing text for further analysis.
Basic Markdown Removal
This feature allows you to remove basic Markdown formatting such as headers, bold, and italic text from a string.
const removeMd = require('remove-markdown');
const markdownText = '# Hello World\nThis is a **bold** statement.';
const plainText = removeMd(markdownText);
console.log(plainText); // Output: 'Hello World\nThis is a bold statement.'
Handling Links
This feature strips Markdown link syntax, leaving just the link text.
const removeMd = require('remove-markdown');
const markdownText = '[Google](https://www.google.com) is a search engine.';
const plainText = removeMd(markdownText);
console.log(plainText); // Output: 'Google is a search engine.'
Handling Images
This feature removes Markdown image syntax, leaving just the alt text.
const removeMd = require('remove-markdown');
const markdownText = '![Alt text](https://example.com/image.jpg) is an image.';
const plainText = removeMd(markdownText);
console.log(plainText); // Output: 'Alt text is an image.'
Turndown is a library that converts HTML into Markdown. While it primarily focuses on converting HTML to Markdown, it can also be used to strip HTML tags, which can be useful for similar purposes as remove-markdown.
Marked is a fast, low-level Markdown parser that can be used to convert Markdown to HTML. While its primary function is not to strip Markdown, it can be used in conjunction with other tools to achieve similar results.
Showdown is a bidirectional Markdown to HTML converter. It can be used to convert Markdown to HTML and then strip the HTML tags to get plain text, providing a similar end result to remove-markdown.
remove-markdown is a node.js module that will remove (strip) Markdown formatting from a text. "Markdown formatting" means pretty much anything that doesn’t look like regular text, like square brackets, asterisks etc.
The typical use case is to display an excerpt of a Markdown text, without the actual Markdown (or rendered HTML, for that matter), for example in a list of posts.
npm install remove-markdown
const removeMd = require('remove-markdown');
const markdown = '# This is a heading\n\nThis is a paragraph with [a link](http://www.disney.com/) in it.';
const plainText = removeMd(markdown); // plainText is now 'This is a heading\n\nThis is a paragraph with a link in it.'
You can also supply an options object to the function. Currently, the only two options are for stripping list leaders and supporting Github Flavored Markdown:
var plainText = removeMd(markdown, {
stripListLeaders: false,
gfm: false
}); // The default for both is true
Setting stripListLeaders
to false will retain any list characters (*, -, +, (digit).
).
PRs are very much welcome.
The code is based on Markdown Service Tools - Strip Markdown by Brett Terpstra.
Stian Grytøyr
FAQs
Remove Markdown formatting from text
The npm package remove-markdown receives a total of 217,322 weekly downloads. As such, remove-markdown popularity was classified as popular.
We found that remove-markdown demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.