remarkjs / strip-markdown Goto Github PK
View Code? Open in Web Editor NEWplugin remove Markdown formatting
Home Page: http://remarkjs.github.io/strip-markdown
License: MIT License
plugin remove Markdown formatting
Home Page: http://remarkjs.github.io/strip-markdown
License: MIT License
Option to keep list characters
I'm using this module for a feature for exporting Markdown to TXT. Unfortunately, after processing the MD with this plugin, lists are no longer recognizable as such because the list characters (e.g. -
) are removed.
I understand that removing this information is what the plugin is supposed to do. For my use case, however, it would be nice to have an option to keep these list characters in the output.
I completely understand if this is not something you'd like to integrate or if you'd rather not provide options for the plugin. If so, feel free to close this issue :)
When strip-markdown
encounters a link
node without children, it throws Cannot use 'in' operator to search for 'length' in undefined
. This is because mapFiltered.link
expects node.children
.
[email protected]
, [email protected]
const unified = require('unified')
const strip = require('strip-markdown')
const ast = {
type: 'root',
children: [
{
type: 'link',
url: '#hash-link',
title: null,
data: {
hProperties: {
'aria-label': 'some info',
class: 'anchor'
},
hChildren: [
{
type: 'raw',
value: '<svg></svg>'
}
]
}
}
]
}
unified()
.use(strip)
.runSync(ast)
Don't crash
Crash
Strings starting with <p>...</p>
cause everything else to be dropped.
remark()
.use(strip)
.process('<p>foo</p> bar', function(err, file) {
if (err) throw err
console.log(String(file))
})
Actual: ""
Expected: "foo bar"
With some text before the tag, it works as expected:
remark()
.use(strip)
.process('foo <p>bar</p>', function(err, file) {
if (err) throw err
console.log(String(file))
})
Actual: "foo bar"
The issue can also be reproduced on the demo, just enter:
<p>foo</p>
bar
<p>
tag should be stripped and the inner text should be returned. This behavior works with other tags like <span>
.
<p>foo</p> bar
returns an empty string, but foo <p>bar</p>
returns "foo bar".
Just followed the demo at README:
var strip = require('strip-markdown');
var mdast = require('mdast').use(strip);
var ast = mdast.parse('Some *emphasis*, **strongness**, and `code`.');
var doc = mdast.stringify(ast);
console.log(doc);
That yields Some _emphasis_, **strongness**, and
code.
. Any idea why?
Currently, when headings are removed, the text is just concatenated.
Edit: Sorry, this might actually be a bug. It only happens if there are thematicBreak
s and they are being removed (default).
Example:
# Foo
## Bar
---
## Testing
becomes
FooBarTesting
I'm not sure exactly, I will investigate.
This is not exactly a feature btw
Hey! Since this lib is a plugin to another one (remark
) it would be nice to put remark
as a peer dependecy thus users will be aware of which version of remark
is supported ^^
basically npm install --save-peer remark@^13.0.0
[email protected], [email protected]
No response
[
The output is [
.
The output is \[
.
I am not sure if this is intentional escaping or a bug.
I have a string of Markdown, and I want to convert it to plain text. With the current behavior, I will end up displaying backslashes that were not in the original text.
Node v16
yarn 2
macOS
Other (please specify in steps to reproduce)
Typescript support
No typing support for this module :(
Is there a way we can disable alt text for images ?
First of all, thanks a lot for the work on Remark!
I've seen that Remark now has TypeScript definitions included since the latest release. It would be great if they could also be added to this plugin :)
remark: 15.0.1, strip-markdown: 6.0.0
No response
Run the following code remark().use(strip).processSync("Testing*").toString().trimEnd()
I'm using Node 20 and npm 10.2.4 and the code was run in Chrome 123.0.6312.107
the result should be Testing*
The result is Testing\*
Other (please specify in steps to reproduce)
Other (please specify in steps to reproduce)
Windows
Vite
Seems like HTML comments should just be stripped, but instead putting one on a line causes that entire line to be ignored. I couldn't really tell if this was a bug in the parser or the strip plugin - hope I guessed correctly ;)
Here's a testcase:
'use strict';
const strip = require('strip-markdown'),
remark = require('remark'),
processor = remark().use(strip);
const body = '<!-- comment -->foobar'; // It doesn't matter if there's a space before `foobar`
const plaintext = String(processor.processSync(body));
console.log(plaintext); // should be "foobar" but is "" instead
Version information:
% node -v
v4.8.0
% npm ls remark strip-markdown
[email protected] /Users/alex/Development/HTTPS-Everywhere/utils/issue-format-bot
├── [email protected]
└── [email protected]
Thanks for maintaining remark <3
var remark = require('remark')
var strip = require('strip-markdown')
remark()
.use(strip)
.process('|a|s||-|-||a|a|', function(err, file) {
if (err) throw err
console.log(String(file))
})
6.0.0
No response
node v21.7.3
unified()
// ...
.use(stripMarkdown)
// ...
No type error
No overload matches this call.
Overload 1 of 3, '(preset?: Preset | null | undefined): Processor<Root, undefined, undefined, undefined, undefined>', gave the following error.
Type '(options?: Readonly<Options> | null | undefined) => (tree: Root) => Root' has no properties in common with type 'Preset'.
Overload 2 of 3, '(list: PluggableList): Processor<Root, undefined, undefined, undefined, undefined>', gave the following error.
Argument of type '(options?: Readonly<Options> | null | undefined) => (tree: Root) => Root' is not assignable to parameter of type 'PluggableList'.
Overload 3 of 3, '(plugin: Plugin<[], Root, Root>, ...parameters: [] | [boolean]): Processor<Root, undefined, undefined, Root, Root>', gave the following error.
Argument of type '(options?: Readonly<Options> | null | undefined) => (tree: Root) => Root' is not assignable to parameter of type 'Plugin<[], Root, Root>'.
Type '(tree: Root) => Root' is not assignable to type 'void'.ts(2769)
It seems like the .use(...)
method wants the plugin to return nothing (void
). Passing stripMarkdown as () => void
fixes the type error
Other (please specify in steps to reproduce)
pnpm
macOS
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.