import static eu.svjatoslav.commons.file.IOHelper.getFileContentsAsString;
import static eu.svjatoslav.commons.string.tokenizer.Terminator.TerminationStrategy.DROP;
import static eu.svjatoslav.commons.string.tokenizer.Terminator.TerminationStrategy.PRESERVE;
+import static eu.svjatoslav.sixth.core.document.text.FormattedText.fromOrg;
public class OrgParser {
+ private Document document;
+
public Document parse(File file) throws IOException, InvalidSyntaxException {
- Document document = new Document();
+ document = new Document();
Tokenizer lineTokenizer = getFileToLineTokenizer(getFileContentsAsString(file));
return;
if (token.token.startsWith("*")){
- System.out.println("LINE: " + line);
- System.out.println(token);
- System.out.println();
+ parseHeading(token);
+ return;
}
}
+ private void parseHeading(TokenizerMatch token) {
+ int level = token.token.length()-1;
+ document.createHeading(fromOrg(token.reminder), level);
+ }
private Tokenizer getLineTokenizer(String contents) {
final Tokenizer tokenizer = new Tokenizer(contents);