在网页上显示Ruby代码的最佳方式?
问题描述:
什么是在网页上显示Ruby代码的最佳工具?在网页上显示Ruby代码的最佳方式?
你是怎么做的?
(类似 http://www.khelll.com/blog/ruby/stackoverflow-cool-ruby-questions-4/
答
有很多这样的工具堆栈溢出使用google-code-prettify如果你喜欢的代码格式张贴在这里,你可能想使用Ruby示例:。
<pre class="prettyprint lang-ruby">
def sum(n)
result = 0
i = 1
while i <= n
result += i
i += 1
end
return result
end
</pre>
结果将是这样的:
def sum(n)
result = 0
i = 1
while i <= n
result += i
i += 1
end
return result
end
+0
我没有在其中看到任何“lang-ruby”:http://code.google.com/p/google-code-prettify/source/browse/trunk/src 。我错过了什么? – Eduardo 2014-01-22 22:34:16
答
我喜欢谷歌代码美化工程: http://google-code-prettify.googlecode.com/svn/trunk/README.html
请注意,如果您使用的轨道,你可能将不得不使用的代码,以显示simple_format视图助手。
<%= simple_format(@blogpost) %>
的
可能重复[哪个语法高亮与导出为HTML(为博客)选择?(http://stackoverflow.com/questions/4112314/which-syntax-highlighter-with-export-to -html-for-blog-to-choose) – Nakilon 2011-01-06 14:30:22