-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option to disable escaping #33
Comments
Why do you want what you want? Indeed, this plugin still generates markdown. That is intended. It removes the working things, so headings turn into paragraph. Some humans want what you want. Some users want what is happening right now. It’s not possible to do what you want here. This is not the place that deals with escapes. |
I need to display to the users a plain-text representation from the markdown. Hence, it should be user-friendly, easy to read, the text from headings and paragraphs should have their own rows etc.
I understand and agree. In fact this is exactly why I was asking for a configurable option, so the default behavior doesn't need to be changed. I went through the older discussions that were related to escaping.
Okay. Could you please point me to the right direction, how could i achieve what i need, using remark and maybe some of the related plugins? |
It’s vague what “this” is. You call it “plain-text representation”. HTML is a standard. Markdown mostly standards but also at least reference implementations and agreements. Plain-text is not a standard. For me to answer you thoroughly, we’d need to cover all possible markdown input cases. Talk about what output you want for each possibility. Then we can make that. Now I don’t know what “representation” you have in your head.
As you say “display”, why not get HTML out: import { unified } from "unified";
import remarkParse from "remark-parse";
import stripMarkdown from "strip-markdown";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
const file = unified()
.use(remarkParse)
.use(stripMarkdown)
.use(remarkRehype)
.use(rehypeStringify)
.processSync("**H&M**");
console.log(String(file)); <p>H&M</p> |
Let me try to clarify: what i mean by plain-text representation / version is, actually, only the text with no markup (be that markdown or HTML). However, as i mentioned in a previous message, a block part like the heading should be on its own row, not mixing up with the next paragraph, for example. |
Well, that’s all a bit short, but I think that matches the HTML example I have, as it gives you HTML that you can display to users, those |
@ninja7dev It looks like you’re not trying to produce markdown, so you don’t need to handle escaping. I think you’re looking for something like this: import {fromMarkdown} from 'mdast-util-from-markdown'
import {toString} from 'mdast-util-to-string'
const ast = fromMarkdown('**H&M**')
const content = toString(ast) |
It seems like this still returns markup (HTML).
Thank you, but I've had previously tried this solution. It results in inlining headings, paragraphs, lists into a big paragraph of text. |
So I understand it’s close to what you want? It’s just not exactly what you want. |
This comment has been minimized.
This comment has been minimized.
Closing as this issue seems not actionable after discussing it for a while. |
Initial checklist
Problem
I'm trying to extract the text from a markdown chunk and getting "
H\&M
" instead of "H&M
".The actual code:
Solution
Could we please make an option to disable the char escaping, for those who need it?
I saw some older issues/discussions created around this repo but couldn't find a working solution.
Alternatives
The text was updated successfully, but these errors were encountered: