本文介绍了WMD编辑器,导轨,指南针:如何将生成的Markdown代码读取为HTML并显示为“富文本格式"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常喜欢WMD在我的应用程序中表现良好.但是,我有一个问题.

I quite like that WMD is behaving nicely with my app. However, I have one problem.

基本上,我编辑内容并将其作为markdown存储在数据库中.然后,我使用 Kramdown 来获取视图的HTML.但是,Kramdown为我提供了我的浏览器无法读取的HTML标记.我使用的是Chrome.

Basically I edit content and store it as markdown in my database. Then I use Kramdown to get the HTML for the views. However Kramdown gets me the HTML tags which are not read by my browser. I use Chrome.

即使用户输入了例如粗体,斜体,代码等.

Sanitizing it will give a plain text even when the user has entered e.g. bold, italic, code etc.

因此,基本思想是将生成的HTML阅读为HTML和富文本格式".

So the basic idea is to get the generated HTML read as HTML and as 'rich-text'.

检查输出源,我发现如果使用Kramdown::Document.new(text).to_html,则会出现一些"引号,如下所示:"<p> ...<em>..</em>.. </p>"

Inspecting the output source, I find that if I use Kramdown::Document.new(text).to_html there are some " " quotes introduce like this: "<p> ...<em>..</em>.. </p>"

这些引号在引号后隐藏了真正的HTML代码...(我认为)

These quotes hide the really HTML code after the quotes...(I assume)

并加上引号已消失:<p> ...<em>..</em>.. </p>,但我最终得到纯文本.

and with sanitize the quotes are gone: <p> ...<em>..</em>.. </p> but I end up with plain text.

我在这里想念什么?我可以让我的浏览器看到我的字体是粗体,还是斜体,段落,图片等...

What am I missing here? Can I make my browser see that I have bold, or i have italic, a paragraph, an image etc...

我必须对HMTL转换器使用kramdown或类似的markdown吗?

Must I use kramdown or similar markdown to HMTL converters?

非常感谢!

更新

我在样式表中使用罗盘.指南针卸载后,WMD编辑器可以正常工作.出于某些原因,指南针似乎在我的application.html.erb文件中隐藏了包括测试文本"在内的所有样式,但使用.scss局部文件创建了那些样式!我的意思是,例如,当以下代码写在application.html.erb文件中时,它不会显示为粗体. <strong> test bold </strong>

I use compass for my stylesheets. When compass is uninstalled WMD editor works fine and correctly. For some reasons, it seems, compass hides any styles including 'test text' in my application.html.erb file but those created with its .scss partials files! I mean for example the following code when written in my application.html.erb file does not display as bold. <strong> test bold </strong>

为什么会发生这种情况?

Any ideas why this happens?

推荐答案

我已经找到解决方案.

问题在于生成的指南针样式包括以下代码段:

The problem was that the generated compass styles includes the following code segment:

body.bp {
  @include blueprint-typography(true);
  @include blueprint-utilities;
  @include blueprint-debug;
  @include blueprint-interaction;
  // Remove the scaffolding when you're ready to start doing visual design.
  // Or leave it in if you're happy with how blueprint looks out-of-the-box
}

在样式表中,我忽略了包含.bp类的内容.现在一切都很好...

In my stylesheets I had ignored to include the .bp class. All is good now...

这篇关于WMD编辑器,导轨,指南针:如何将生成的Markdown代码读取为HTML并显示为“富文本格式"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 03:36