javascript - Markdown 文件无法与 js 库一起正常工作,换行问题
问题描述
我正在使用 react-markdown 来呈现降价。我将 .md 文件的内容传递给它,但它无法正常工作,换行符有问题。但它在这样的在线降价查看工具中运行良好。
我的降价看起来像这样:
- Type some Markdown on the left
- See HTML in the right
- Magic
# New Features!
- Import a HTML file and watch it magically convert to Markdown
- Drag and drop images (requires your Dropbox account be linked)
解决方案
这里降价的问题是,它应该是一个单行字符串,其中换行符由 \n 表示。
那就是上面的降价应该是这样的。
- Type some Markdown on the left\n - See HTML in the right \n - Magic \n \n# New Features! \n \n - Import a HTML file and watch it magically convert to Markdown \n - Drag and drop images (requires your Dropbox account be linked)
您可以通过此代码实现此格式
mardownContent.replace(/\n/g,' \\n')
或者来自下面的 vscode
推荐阅读
- python - “write() 参数必须是 str,而不是字节”
- reactjs - TypeError:未定义不是对象(评估“movies.map”)
- amazon-web-services - 从 S3 托管的网站访问 Lambda 函数时出现 CORS 错误
- c++ - 为什么我分配对象本身不能正常工作?
- flutter - 一个关于 Flutter 响应性的快速问题
- reactjs - React api 调用的 Windows 身份验证
- python - 使用用户输入搜索文件
- excel - VBA - 如何一起使用工作表和范围变量?
- latex - 证明在自定义环境中不起作用(LaTeX)
- flutter - 使用颤振,刚刚遇到以下错误,表明范围值无效