         //
         // cleanNewlines()
         
-        for (index, node) in rootNode.children.enumerated() {
+        while index < rootNode.children.count {
+            let node = rootNode.children[index]
             
-            guard let textNode = node as? TextNode else {
-                rootNode.children.remove(at: index)
-                nodesToWrapInParagraph.append(node)
+            guard var textNode = node as? TextNode else {
+                index += 1
                 continue
+            }
+            /*
+            if let range = textNode.text().rangeOfCharacter(from: .newlines) {
+                if let nextRange = textNode.text().rangeOfCharacter(from: .newlines),
+                    nextRange.lowerBound == range.upperBound {
+                    
+                    // Paragraph ending
+                    
+                    split(textNode)
+                    
+                    let nodesToWrap = rootNode.children.dropFirst(startIndex).dropLast(endIndex)
+                } else {
+                    // Single line break
+                    
+                    let leftText = textNode.text().substring(to: range.lowerBound)
+                    let rightText = textNode.text().substring(from: range.upperBound)
+                    
+                    let leftTextNode = TextNode(text: leftText)
+                    let brNode = ElementNode(type: .br)
+                    let rightTextNode = TextNode(text: rightText)
+                    
+                    rootNode.children.remove(at: index)
+                    rootNode.children.insert(rightTextNode, at: index)
+                    rootNode.children.insert(brNode, at: index)
+                    rootNode.children.insert(leftTextNode, at: index)
+                }
             }
             
             guard let elementNode = node as? ElementNode else {


class ParagraphRemovingProcessor: HTMLTreeProcessor {
    func process(_ rootNode: RootNode) -> RootNode {
        // All nodes at the root level that are not block nodes will be wrapped by paragraphs.
        var nodesToWrapInParagraph = [Node]()

        // First clean BRs:
        // - Converts single \n at root level to <br/>

            
            guard elementNode.standardName != .br else {
                continue
            } */
            // If <br>, with a <br> coming up next, wrap all pending nodes
            // Otherwise add the node to the list of nodes to wrap in a paragraph
        }
