package eu.svjatoslav.sixth.core.document;
+import eu.svjatoslav.commons.string.String2;
import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
import eu.svjatoslav.commons.string.tokenizer.Tokenizer;
import eu.svjatoslav.commons.string.tokenizer.TokenizerMatch;
}
private void parseHeading(TokenizerMatch token) throws InvalidSyntaxException {
- System.out.println("HEADING!! " + token.token);
- int level = token.token.length()-1;
-// createHeading(fromOrg(token.reminder), level);
+ // expected sample heading:
+ // ***** test heading
+
+ String[] headingSections = String2.getGroups(token.token, "(\\*+)[ \\t](.*)\\r?\\n");
+ int level = headingSections[0].length();
+ String title = headingSections[1];
+ createHeading(fromOrg(title), level);
}
public void parse(String fileContentsAsString) throws InvalidSyntaxException {
// Org heading:
// "*** Example Heading 1234"
- tokenizer.addTerminator(PRESERVE, "\\*+\\s.*\\r?\\n", TG_HEADING);
+ tokenizer.addTerminator(PRESERVE, "\\*+[ \\t].*\\r?\\n", TG_HEADING);
// Org list. Examples:
// " + my list title"
- // "+"
- tokenizer.addTerminator(PRESERVE, "\\s*(\\+|-)(\\s.*)?\\r?\\n", TG_LIST);
- tokenizer.addTerminator(PRESERVE, "\\s+\\*(\\s.*)?\\r?\\n", TG_LIST);
+ // " - my list title"
+ tokenizer.addTerminator(PRESERVE, "[ \\t]*(\\+|-)([ \\t].*)?\\r?\\n", TG_LIST);
+
+ // " * my list title"
+ tokenizer.addTerminator(PRESERVE, "[ \\t]+\\*([ \\t].*)?\\r?\\n", TG_LIST);
// DocumentProperty:
// "#+OPTIONS: H:20 num:20"