Ruby on rails 如何在rails中将标记文件转换为trix编辑器格式
我有一堆降价文件作为我的旧应用程序文档,但现在新文档是通过我的应用程序中的Trix编辑器添加的 我尝试使用红毯宝石将标记文件转换为HTML格式,方法如下:Ruby on rails 如何在rails中将标记文件转换为trix编辑器格式,ruby-on-rails,markdown,trix,actiontext,Ruby On Rails,Markdown,Trix,Actiontext,我有一堆降价文件作为我的旧应用程序文档,但现在新文档是通过我的应用程序中的Trix编辑器添加的 我尝试使用红毯宝石将标记文件转换为HTML格式,方法如下: def parsed_body renderer = Redcarpet::Render::HTML markdown = Redcarpet::Markdown.new(renderer, autolink: true, tables: true) markdown.render body end 但这里的
def parsed_body
renderer = Redcarpet::Render::HTML
markdown = Redcarpet::Markdown.new(renderer, autolink: true, tables: true)
markdown.render body
end
但这里的问题是,解析文本与通过Trix编辑器添加的文章正文中存储的操作文本非常不同
我的旧文档采用CommonMark标记格式
article.desc.body.to\u trix\u html
通过trix编辑器添加的文章正文如下:
"<div><br>A customer can add nitrochat on any page of your website/application that you’d like. They provide a quick and simple way for customers to flip through your knowledge base or reach out to your team.<br><br>Follow the steps to add nitrochat to your website:<br>1. Login using your admin account.<br>2. Go to `Chat -> Installation`.<br>3. Select the **Active status** button.<br>4. In **Code snippet** section, copy and insert the following script before the closing body tag (`</body>`) of your website to display the NitroChat in your website.<br><br>**Note:** If you make the NitroChat invisible(by making Active status disabled), you can still open it via JavaScript code using the NitroChat.contextualHelp.openWidget() API.<br>![Chat installation page](https://p50.f0.n0.cdn.getcloudapp.com/items/yAuYw5Kk/Image%202020-07-24%20at%203.33.00%20PM.png?v=2b5a14a907b96de94905d1de24bc9792)<br><br></div>"
"<p>A customer can add nitrochat on any page of your website/application that you’d like. They provide a quick and simple way for customers to flip through your knowledge base or reach out to your team.</p>\n\n<p>Follow the steps to add nitrochat to your website:</p>\n\n<ol>\n<li>Login using your admin account.</li>\n<li>Go to <code>Chat -> Installation</code>.</li>\n<li>Select the <strong>Active status</strong> button.</li>\n<li>In <strong>Code snippet</strong> section, copy and insert the following script before the closing body tag (<code></body></code>) of your website to display the NitroChat in your website.</li>\n</ol>\n\n<p><strong>Note:</strong> If you make the NitroChat invisible(by making Active status disabled), you can still open it via JavaScript code using the NitroChat.contextualHelp.openWidget() API.<br>\n<img src=\"https://p50.f0.n0.cdn.getcloudapp.com/items/yAuYw5Kk/Image%202020-07-24%20at%203.33.00%20PM.png?v=2b5a14a907b96de94905d1de24bc9792\" alt=\"Chat installation page\"></p>"
你的投入是什么,你期望的产出是什么,你得到的是什么。“解析后的文本非常不同”这句话没说多少。我已经编辑了最初的问题,@SiimLiiser感谢你指出。你的输入是什么,你期望的输出是什么,你得到的是什么。“解析后的文本非常不同”并没有太多说明。我已经编辑了最初的问题,@SiimLiiser感谢您指出。