在 rails 中配置 ckeditor 以 Markdown 语法编写,而不是 HTML

Configure ckeditor in rails to write in Markdown syntax as opposed to HTML

在我的应用程序的一部分中,我成功地使用了债权人。它正确地接受输入的文本并将其转换为 html 格式。

内容中的用户类型:

并且它以 html 语法正确保存内容:

在我的应用程序的另一个地方,我想再次使用 ckeditor。但是:这次我希望将内容转换为 Markdown 语法,而不是 HTML 语法。这可能吗?如果是这样,您如何为应用程序中的这个地方指定该配置(而不是全局指定此规则,因为我希望 ckeditor 在其他任何地方继续将内容转换为 html)。

我确实在 ruby 宝石 ckeditor docs. I also looked through the ckeditor documentation on options 中看过,但是对我来说有点难以理解。

看来您必须添加 markdown addon as it is not part of ckeditor, then follow the documentation

我最终做的是创建一个脚本,将我的应用程序中的数据库字段从 markdown 语法转换为 html 语法。我用 redcarpet Gem and the rdiscount Gem 做了这个。这些字段现在以 html 语法而不是 markdown 语法保存,我呈现文本就像在其他使用 ckeditor 的地方所做的一样。