package net.bloople.stories;

import java.io.IOException;
import java.io.Reader;
import java.util.Scanner;

/**
 * Created by i on 27/05/2016.
 */
public class StoryParser {
    private Scanner scanner;

    public StoryParser(Reader reader) {
        scanner = new Scanner(reader);
        scanner.useDelimiter("(?:\r?\n){2,}+");
    }

    public boolean hasNext() throws IOException {
        return scanner.hasNext();
    }

    public Node next() throws IOException {
        String content = scanner.next();

        if(content.startsWith("#")) {
            return NodeFactory.heading(content);
        }
        else {
            return NodeFactory.paragraph(content);
        }
    }
}

@@ -314,16 +314,31 @@
 (?:%5Cr?%5Cn
+%5B%5Cu200B%5CuFEFF%5D*
 )%7B2,%7D+%22)

Fix story parsing regexp to ignore ZWSP and ZWNBSP characters between newlines