package bloople.net.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("\n\n");
    }

    public void parse(Story story) throws IOException {
        while(scanner.hasNext()) {
            story.add(next());
        }
    }

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

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

@@ -310,12 +310,22 @@
 er(%22
-%5Cn%5Cn
+(?:%5Cr?%5Cn)%7B2,%7D+
 %22);%0A

Fix story parsing to support both windows and linux style newlines; Allow extra newlines between nodes