当我包含 '.html_safe' 时,我发现样式 (lass = 'lead' style = 'font-size: 14px;') 没有被使用。当我删除 .html_safe 时,我得到了样式,但现在显示了所有 html。
关于如何解决这个问题的任何建议?
<p class = 'lead' style = 'font-size: 14px;'>
<div id = 'textcontainer'>
<%= @chapter.chaptext.html_safe %>
</div> <!-- end of textcontainer div -->
</p>
没有 html 的 @chapter.chaptext 的内容:
<p> Sanjaya said: <a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>Lord Krishna</a></a></a></a></a></a></a></a></a> spoke these wor<a href = '#' class = 'getannotation'>ds to Arjuna</a> whose eyes were
<a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>tearful and downcast</a></a>, and who was ov<a href = '#' class = 'getannotation'>erwh</a>elmed <a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>with compassion and despair</a></a>.
(2.01) <p>
<p> The Supreme Lord said: How has the dejection come to you at this
juncture? This is n<a href = '#' class = 'getannotation'>ot fit for an Arya</a>n (or the people of noble mind and
deeds). It is disgraceful, and it does not lead one to heaven, O Arjuna.
(2.02)<br>
<p> Do not become a coward, O Arjuna, because it does not befit you. Shake
off this weakness of your heart and get up (for the battle), O Arjuna.
(2.03) <p>