扩展MaRuKu生成原始html标签,md_html转义html
我正在使用 Insitiki 代码并尝试扩展 maruku 语法以生成一些自定义 html 标签。
示例:
|youtube 0FWPr6u8YF |
应打印 html 代码如下:
<object data='http://www.youtube.com/v/01hcB2zmMqM' style='width:425px; height:350px;' type='application/x-shockwave-flash'><param name='movie' value='http://www.youtube.com/v/01hcB2zmMqM'/></object>
从而给我一个 youtube 嵌入视频。
为了使其工作,我遵循了本教程 http://maruku.rubyforge.org/extending/extensions。 html 并查看了 maruku 文档。
问题是,使用 maruku 方法:
raw htmlcontext.push(doc.md_html("
生成的 html 代码被转义,所以我得到的是逐字文本而不是我想要的原始 html。
我尝试更改策略并使用类似以下内容的内容:
raw raw rawcontext.push(doc.md_el(:raw_html,[],:raw_html => "
没有用...我现在得到的是: REXML 无法解析此 XML/HTML:
在这个问题上没有发现任何内容,maruku 文档非常薄(或者我真的不擅长搜索)...这家伙似乎有类似的问题纺织和maruku问题
任何帮助表示赞赏。
I'm working in the Insitiki code and trying to extend the maruku syntax to generate some custom html tags.
Example:
|youtube 0FWPr6u8YF |
Should print the html code as follows:
<object data='http://www.youtube.com/v/01hcB2zmMqM' style='width:425px; height:350px;' type='application/x-shockwave-flash'><param name='movie' value='http://www.youtube.com/v/01hcB2zmMqM'/></object>
Thus giving me a youtube embbeded video.
To make it work I followed this tutorial http://maruku.rubyforge.org/extending/extensions.html and looked at maruku documentation.
THE PROBLEM is, using the maruku method:
context.push(doc.md_html("<p>raw html</p>"))
The resulting html code is escaped, so what I get is verbatim text and not the raw html that I wanted.
I tried changing the strategy and using something like:
context.push(doc.md_el(:raw_html,[],:raw_html => "<p> raw raw raw </p>")
To no use ... what I get now is: REXML could not parse this XML/HTML:
Found nothing on this issue, the maruku docs are really thin (or I'm really bad at searching)... this guy seems to have a similar problem textile and maruku problem
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我似乎无法在 maruku 版本 0.6.0 下重现此错误。
生成预期结果,没有 html 转义。也许问题已经解决了?
Maruku 对您生成的 HTML 相当严格,所以它可能不喜欢您插入的实际代码,而不是
raw html
供将来参考,这就是我如何成功注册一个跨度扩展以将
:
{{var_name}}
替换为I can't seem to reproduce this bug under maruku version 0.6.0.
Generates the expected result, with no html escaping. Maybe the problem has been fixed?
Maruku is rather strict about the HTML you are generating though, so maybe it doesn't like something about the actual code you are inserting instead of
<p>raw html</p>
For future reference, this is how I managed to register a span extension to replace
{{var_name}}
with<span class='text_var' text_var='var_name'> </span>
under maruku 0.6.0: