You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've been working on a component recently where we want to support only a subset of the element, basically only paragraph, strong and link for now.
For example:
This is some **markdown** text. Here a some link,
just [here](https://www.google.com). And some random text.
- Bullet point 1
- Bullet point 2
Would render the appropriate bold, link and paragraph tag but for the bullet point, I want it to be rendered raw.
Is there a way to do that with the library? I've tried to only use my rules and not spread the default one but I have an error when I do that
You should be able to do that with only your rules and not spreading the default, with one addition: you'll need the text rule to specify what happens to text that isn't matched by another rule (likely where your error was coming from).
construles={paragraph: {
...SimpleMarkdown.defaultRules.paragraph,react: (node,output,state)=>(<Textkey={state.key}size="text-100">{output(node.content,state)}</Text>),},// ... the other rules you want heretext: SimpleMarkdown.defaultRules.text,};
One thing you might run into with the bullet points is that by default markdown treats multiple lines like that as part of a paragraph and ignores the line break.
You could probably change this behaviour by parsing the list and then changing the rendering to output the raw dashes rather than a <li>, or by preprocessing the text to replace all \ns with \n (two spaces followed by a newline) and including the br rule, which turns \n into a <br> element to separate the lines.
(Alternatively, if those don't work, you could change the br rule to match \n: match: anyScopeRegex(/^\n/), and change the text rule to break on newlines: match: anyScopeRegex(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]|\n|\w+:\S|$)/)
Hi, I've been working on a component recently where we want to support only a subset of the element, basically only
paragraph
,strong
andlink
for now.For example:
Would render the appropriate bold, link and paragraph tag but for the bullet point, I want it to be rendered raw.
Is there a way to do that with the library? I've tried to only use my rules and not spread the default one but I have an error when I do that
The text was updated successfully, but these errors were encountered: