Comments (7)
You can vanish the paragraph tag with a React.Fragment
.
return (
<ReactMarkdown
components={{
p: React.Fragment,
}}
>
{children}
</ReactMarkdown>
)
from react-markdown.
Sorry for not responding earlier, I've been a bit busy with life. You could set Paragraph
as a disallowedTypes
and set unwrapDisallowed
to true
. That'll make it a bit hard to handle newlines properly, though - not sure how you want to treat those? Example:
<Markdown
source="Normally, this *sentence* would be wrapped in a paragraph."
disallowedTypes={['Paragraph']}
unwrapDisallowed
/>
Or, you could just replace the renderer for paragraphs with something else:
<Markdown
source="Normally, this *sentence* would be wrapped in a paragraph."
renderers={{Paragraph: 'span'}}
/>
This would render <span>
instead of <p>
, which might not be what you want, but you can use a custom react component instead if you want. Take a look at the readme for more information on the custom renderer feature.
from react-markdown.
This doesn't work in v4.0, please confirm.
Seems like Paragraph
got converted to lowercase paragraph
. With the lowercase naming it does work.
from react-markdown.
Note that as of 2021 (version ???), the parameter names have changed a bit:
<ReactMarkdown
components={{ p: "span" }}
...
>
{children}
</ReactMarkdown>
And allowedElements
/ disallowedElements
instead of allowedTypes
/ disallowedTypes
from react-markdown.
You can also enable unwrapDisallowed
to true
.
My code:
const markdownTypesAllowed = [ 'text', 'strong', 'delete', 'emphasis', 'link' ];
<Markdown source={text} allowedTypes={markdownTypesAllowed} unwrapDisallowed={true} />
from react-markdown.
I was wondering this as well. It would be good if there was some way to avoid having the enclosing <p>
tags.
from react-markdown.
This doesn't work in v4.0, please confirm.
Seems like
Paragraph
got converted to lowercaseparagraph
. With the lowercase naming it does work.
paragraph: 'p',
with lowercase p
react-markdown/src/renderers.js
Line 13 in 634f88d
from react-markdown.
Related Issues (20)
- How to append content ,not cover? HOT 2
- When using two **enclosed bold texts containing colons, react-markdown fails to correctly parse the bold syntax. HOT 3
- Please add syntax for `{.tabset} ` HOT 2
- Typescript error while using syntax hightlight part code from README.md HOT 4
- sup element rendering with remark-gfm plugin is painfully slow. HOT 7
- React 18.3.0/19.0.0 support for react-markdown ^6.0.0 HOT 2
- React-markdown isn't rendering phone number links anymore HOT 3
- rst support HOT 2
- Can't drag-over select text to copy a section HOT 3
- Headings and subheadings aren't getting rendered (NextJS 14/ChakraUI) HOT 3
- Invalid HTML syntax together with `rehype-raw` causes crash HOT 6
- Incorrect Languageless Code Block Rendering in Example HOT 12
- Identify `last-child` HOT 3
- Compatible with lower version browsers HOT 3
- TypeError: (0 , unist_util_visit__WEBPACK_IMPORTED_MODULE_1__.visit) is not a function HOT 3
- Syntex for showing underlined text HOT 3
- would it be avaliable for yarn HOT 2
- Support Automatic Link Detection and Hyperlinking HOT 4
- custom syntax and custom components are not working HOT 3
- github attached videos HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
tag
from react-markdown.