Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Strip some useless information from the display of a title

  • Loading branch information...
commit 919c61a6c23cd81e4ec1efef5a09084ab84f3115 1 parent 98ad052
@matburt authored
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/com/matburt/mobileorg/OrgFileParser.java
View
17 src/com/matburt/mobileorg/OrgFileParser.java
@@ -13,7 +13,6 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
-
import android.text.TextUtils;
import android.util.Log;
@@ -76,6 +75,20 @@ private TitleComponents parseTitle (String orgTitle) {
return component;
}
+ private String stripTitle(String orgTitle) {
+ Pattern titlePattern = Pattern.compile("<before.*</before>|<after.*</after>");
+ Matcher titleMatcher = titlePattern.matcher(orgTitle);
+ String newTitle = "";
+ if (titleMatcher.find()) {
+ newTitle += orgTitle.substring(0, titleMatcher.start());
+ newTitle += orgTitle.substring(titleMatcher.end(), orgTitle.length());
+ }
+ else {
+ newTitle = orgTitle;
+ }
+ return newTitle;
+ }
+
public void parse() {
String thisLine;
Stack<Node> nodeStack = new Stack();
@@ -117,7 +130,7 @@ public void parse() {
//headings
if (numstars > 0) {
String title = thisLine.substring(numstars+1);
- TitleComponents titleComp = parseTitle(title);
+ TitleComponents titleComp = parseTitle(this.stripTitle(title));
Node newNode = new Node(titleComp.title, Node.NodeType.HEADING);
newNode.todo = titleComp.todo;
newNode.tags.addAll(titleComp.tags);
Please sign in to comment.
Something went wrong with that request. Please try again.