Skip to content

Commit c63e24b

Browse files
committed
Fix PROPERTY line regex
Fixes orgzly/orgzly-android#726.
1 parent ae9aa91 commit c63e24b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/main/java/com/orgzly/org/OrgPatterns.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public class OrgPatterns {
4141
public static final Pattern HEAD_PRIORITY_P = Pattern.compile("^\\s*\\[#([A-Z])](.*)");
4242
public static final Pattern HEAD_TAGS_P = Pattern.compile("^(.*)\\s+:(\\S+):\\s*$");
4343

44-
public static final Pattern PROPERTY = Pattern.compile("^:([^:\\s]+):(\\s+.+|)$");
44+
// org-property-re
45+
public static final Pattern PROPERTY = Pattern.compile("^[ \\t]*:(\\S+):(|[ \\t]+.*?[ \\t]*)$");
4546

4647
/*
4748
https://orgmode.org/manual/In_002dbuffer-settings.html

src/test/java/com/orgzly/org/OrgPropertiesTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,22 @@ public void compositeWithBreak() throws IOException {
169169
Assert.assertEquals(4, head.getProperties().size());
170170
Assert.assertEquals("c d", head.getProperties().get("KEY"));
171171
}
172+
173+
@Test
174+
public void headerArguments() throws IOException {
175+
String fileContent =
176+
"* Test heading\n" +
177+
":PROPERTIES:\n" +
178+
":header-args: :cache yes\n" +
179+
":header-args:python:: :results output\n" +
180+
":END:";
181+
182+
OrgParsedFile file = parserBuilder.setInput(fileContent).build().parse();
183+
OrgHead head = file.getHeadsInList().get(0).getHead();
184+
185+
Assert.assertTrue(head.hasProperties());
186+
Assert.assertEquals(2, head.getProperties().size());
187+
Assert.assertEquals(":cache yes", head.getProperties().get("header-args"));
188+
Assert.assertEquals(":results output", head.getProperties().get("header-args:python:"));
189+
}
172190
}

0 commit comments

Comments
 (0)