         openScopeNode = openScopeNode.parentElement
 
       for scope in @tokenIterator.getScopeStarts()
-        newScopeNode = document.createElement("span")
-        newScopeNode.className = scope.replace(/\.+/g, ' ')
+        newScopeNode = @buildElement("span", scope.replace(/\.+/g, ' '))
         openScopeNode.appendChild(newScopeNode)
-
         openScopeNode = newScopeNode
 
       tokenStart = @tokenIterator.getScreenStart()


  appendToken: (scopeNode, tokenText, isHardTab, firstNonWhitespaceIndex, firstTrailingWhitespaceIndex, hasIndentGuide, hasInvisibleCharacters) ->
    if isHardTab
      hardTab = document.createElement("span")
      hardTab.classList.add("hard-tab")
      hardTab.classList.add("leading-whitespace") if firstNonWhitespaceIndex?
      hardTab.classList.add("trailing-whitespace") if firstTrailingWhitespaceIndex?
      hardTab.classList.add("indent-guide") if hasIndentGuide
      hardTab.classList.add("invisible-character") if hasInvisibleCharacters
      hardTab.textContent = tokenText

      scopeNode.appendChild(hardTab)
    else

    if endOfLineInvisibles?
      for invisible in endOfLineInvisibles
        hasInvisibles = true
        lineNode.appendChild(
          @buildElement("span", "invisible-character", invisible)
        )

    hasInvisibles

