     else
       @appendLineInnerNodes(id, lineNode)
 
-    if fold
-      foldMarker = document.createElement("span")
-      foldMarker.classList.add("fold-marker")
-      lineNode.appendChild(foldMarker)
-
+    lineNode.appendChild(@buildElement("span", "fold-marker")) if fold
     lineNode
+
+  buildElement: (name, className, textContent) ->
+    element = document.createElement(name)
+    element.className = className if className?
+    element.textContent = textContent if textContent?
+    element
 
   appendEmptyLineInnerNodes: (id, lineNode) ->
     {indentGuidesVisible} = @newState

    {width} = @newState
    {screenRow, tokens, text, top, lineEnding, fold, isSoftWrapped, indentLevel, decorationClasses} = @newTileState.lines[id]

    lineNode = document.createElement("div")
    lineNode.classList.add("line")
    if decorationClasses?
      for decorationClass in decorationClasses
        lineNode.classList.add(decorationClass)

        openScopeNode = openScopeNode.parentElement

      for scope in @tokenIterator.getScopeStarts()
        newScopeNode = @buildElement("span", scope.replace(/\.+/g, ' '))
        openScopeNode.appendChild(newScopeNode)
        openScopeNode = newScopeNode

      tokenStart = @tokenIterator.getScreenStart()
