     if indices?
       if typeof indices is 'number' then indices = [indices]
     else
-       indices = [0 ... len]
+      indices = [0 ... len]
     sel = window.getSelection()
     sel.removeAllRanges()
 #    (sel.addRange results.matches[index].range) for index in indices when 0 <= index < len

      insert: toInsert
      remove: toRemove

  # Call this to undo a highlighting task
  #
  # It's your responsibility to only call this if a highlight is at place.
  # (Altought calling it more than once will do no harm.)
  # Pass in the task that was used with the highlighting.
  undo: (task) ->
    unless task?.undo? then return
    insert.before.parentNode.insertBefore insert.node, insert.before for insert in task.undo.insert
    remove.parentNode.removeChild remove for remove in task.undo.remove
    delete task.undo
  
        
  # ===== Private methods (never call from outside the module) =======

  constructor: (domTextMapper) ->
    hl = document.createElement "span"
    hl.setAttribute "style", "background-color: yellow; color: black; border-radius: 3px; box-shadow: 0 0 2px black;"
    @standardHilite = hl

  hilite: (node, template) ->
    parent = node.parentNode

    hiliteTemplate ?= @standardHilite

    len = task.ranges.length
#    console.log "Got " + len + " ranges."
    if indices?
      if typeof indices is 'number' then indices = [indices]
    else
#      console.log "Got no indices to start with"
      if len
#        console.log "Creating full indices"
        indices = [0 ... len]
      else
#        console.log "Nothing to do"
        return
#    console.log "Indices are: "
#    console.log indices

    # Prepare data structures for undo   
    toInsert = []
