truncate rendered markdown with react-markdown #192
-
Maybe I am not using it right, but I was trying to truncate the text from my markdown using import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
import rehypeInferDescriptionMeta from "rehype-infer-description-meta";
const markdownContent =
const component = () => {
return (
<Markdown
disallowedElements={
previewLines
? ["h1", "h2", "h3", "h4", "h5", "h6", "hr"]
: []
}
unwrapDisallowed
remarkPlugins={[remarkGfm]}
rehypePlugins={[
[rehypeInferDescriptionMeta, { truncateSize: 10 }],
]}
>
{markdownContent}
</Markdown>
)
} versions:
What am i doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
@benjaminpreiss Your example doesn't make much sense. Take some time to frame your question to help us help you https://github.com/rehypejs/.github/blob/main/support.md |
Beta Was this translation helpful? Give feedback.
There are lots of plugins that could help https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins 🙂
It sounds like you're looking for something more like https://github.com/luk707/rehype-truncate ?