我想放一个新的纺织品标签,像h1.,但是它的名字是map.。
所以我找到了下列条款,但在RedCloth 4.2.2上不起作用。
谢谢
发布于 2010-03-14 06:30:51
有一个关于如何在雷德克洛斯规格中使用自定义标记的示例。基本上,您将需要的新方法放在一个模块中,然后将其传递给RedCloth对象的扩展方法。
下面是一个自定义标记的快速示例,它将调用的文本放在一个span中:
module MappingExtension
def map(opts)
html = %Q{<span class="map">#{opts[:text]}</span>\n}
end
end
require 'redcloth'
text = "The next line will contain a map:\n\nmap. map"
r = RedCloth.new text
r.extend MappingExtension
r.to_html
# "<p>The next line will contain a map:</p>\n<span class="map">map</span>\n"如果您想在Rails项目中使用它,您可能需要覆盖ActionView的特发性文本助手,以便它用自定义标记扩展RedCloth。
https://stackoverflow.com/questions/2439239
复制相似问题