Search code examples
htmlace-editor

The ace editor not displaying some code


I'm using the ace editor and I noticed when I read in some lua file it wasn't matching 100% to what the file really had in it when I placed the data inside the ace editor div. You can see this effect at the link below. Notice how in the html there is a lot more lua code but in the result only 1 line is shown. Is there a different way to add code to the ace editor so that all of it will be displayed?

http://jsfiddle.net/wcevdmke/

<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
             <h3 class="panel-title">Editor</h3>
        </div>
        <div class="panel-body">
<div id="editor">--if d<self.senseradius then
--  return entity.script
--else
--  local p = Transform:Point(entity:GetPosition(),nil,self.entity)
--  if (p.z>-math.abs(p.x) and p.z<-math.abs(p.y)) then
</div>
        </div>
    </div>
    <div class="text-center">---End of editor---</div>
</div>

Solution

  • Browser parses <self as a tag before passing it to ace. You need to escape special html characters by replacing & by &amp; and < by &lt;