[英]Line seperators are not present in rendered markdown using react-markdown
I am using react-markdown
to render a markdown. The text content is rendered correctly but I cannot view the line separators under the heading and for the table.我正在使用
react-markdown
呈现 markdown。文本内容呈现正确,但我无法查看标题下和表格的行分隔符。 I tried pasting the same content in the demo https://remarkjs.github.io/react-markdown/
and it renders correctly with the line separators.我尝试在演示
https://remarkjs.github.io/react-markdown/
中粘贴相同的内容,它使用行分隔符正确呈现。
Following is the codesandbox link for the implementation.以下是实现的 codesandbox 链接。 https://codesandbox.io/s/strange-firefly-zzv3r?file=/src/App.js .
https://codesandbox.io/s/strange-firefly-zzv3r?file=/src/App.js 。 Note: The table does not have line separators between the rows and columns.
注意:该表在行和列之间没有行分隔符。 To render the table, I am using the
remark-gfm
as mentioned in the documentation for the react-markdown
为了呈现表格,我正在使用
remark-gfm
,如react-markdown
文档中所述
Following is my React component that renders the markdown以下是我的 React 组件,它呈现 markdown
import React, { useEffect, useState } from "react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
export default function App() {
const markdown = `# First Heading
## SomeHeading()
Returns some heading if found to be true .
**Syntax:** "SomeHeading(string; search-text; [case-insensitive])"
|Parameter|Data type|Optional|Text|
|--|--|--|--|
|string|string|NO|The text to search in|
|search-text|string|NO|The string to check|
|case-insensitive|boolean|YES|set “true” if the search should be case insensitive.|
`;
return (
<div className='post'>
<ReactMarkdown children={markdown} remarkPlugins={[remarkGfm]} />
</div>
);
}
In your example all the lines in your markdown start with 2 spaces.在您的示例中,markdown 中的所有行都以 2 个空格开头。 Spaces at the beginning of a line are not meaningless in markdown.
行首的空格在markdown中不是没有意义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.