Skip to content

Commit

Permalink
Strip some useless information from the display of a title
Browse files Browse the repository at this point in the history
  • Loading branch information
matburt committed Apr 26, 2010
1 parent 98ad052 commit 919c61a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/com/matburt/mobileorg/OrgFileParser.java
Expand Up @@ -13,7 +13,6 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;

import android.text.TextUtils;
import android.util.Log;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 919c61a

Please sign in to comment.