我正在尝试使用Syntax Highlighter来使我的嵌入式代码看起来很棒。我可以在html文件上执行此操作,但是当我尝试使用我的rails博客时,它无效。
我的直觉告诉我这与我的控制器有关:
<pre class="brush: ruby;">
puts "Do you use Facebook? (Y/N)"
</pre>
<p>
<b>Entry:</b>
</p>
<%=sanitize @thought.entry %>
但顶部的html位仍然正常运行......
<!DOCTYPE html>
<html>
<head>
<title>Blog</title>
<script src="/assets/shCore.js?body=1" type="text/javascript"></script>
<script src="/assets/shBrushRuby.js?body=1" type="text/javascript"></script>
<link href="/assets/shCoreDefault.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript">SyntaxHighlighter.all();</script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="1OAMJ6dGJ8c7CHunEe9IBkNrcIJwrfYdwtskSFRGvUQ=" name="csrf-token" />
</head>
<body>
<p id="notice"></p>
<p>
<b>Title:</b>
Facehook
</p>
<p>
<b>Entry:</b>
</p>
<pre class="brush: ruby;">
puts "Do you use Facebook? (Y/N)"
facehooked = gets
if facehooked == "Y" #upper- or lower-case?
puts "How many friends do you have?"
friends = gets
if friends > 30
puts "I asked how many friends you have. Not how many friends you have on Facebook. You are Facehooked."
elsif friends == 0
puts "I am sorry to hear that."
else
#How sociable are you in the real world?
#TODO - data-type checking
puts "Please answer the following questions with a number:\nHow many people would you like to see on a weekly basis?"
buddies = gets
puts "How many people do you happen to see on a weekly basis?"
acquaintances = gets
puts "How many people that you do not like do you have to see on a daily basis?"
forced = gets
puts "How many people would you love to see on a daily basis?"
true_friends = gets
people = buddies + acquaintances + forced + true_friends
#ratios
true_friends_to_buddies = true_friends / buddies
buddies_to_acquaintances = buddes / acquaintances
true_friends_to_acquaintances = true_friends / aquaintances
puts "How many 'friends' do you have on Facebook?"
facehooks = gets
if people == 0
puts "You are ninja. You drift among this world without a connection. Please do not kill me."
elsif people >= 500
puts "You are one social motherfucker!"
else
end
end
elsif facehooked == "N"
puts "You do not have a hook in your face. Congratulations."
else
puts "That question required a yes or no answer."
end
puts "You should follow @ricburton on Twitter - he likes talking to new people, making acquaintances and building friendships."
</pre>
<a href="/thoughts/1/edit">Edit</a> |
<a href="/thoughts">Back</a>
</body>
</html>
任何帮助都是非常有用的!
答案 0 :(得分:0)
任何帮助都是非常有用的!
对于rails上的语法高亮显示,我建议通过gem highlighting
使用prism.js
集成非常简单。您可以在此处详细了解如何与导轨集成https://github.com/ytbryan/highlighting