Skip to content

Commit

Permalink
Work on #433. Regex madness for XML tag parsing. This should fix #355
Browse files Browse the repository at this point in the history
but it still doesn't address the remaining issue in #433.
  • Loading branch information
keforbes committed May 15, 2014
1 parent 5998a05 commit 2b753e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,14 @@ public void test_dit() {
checkCommand(forKeySeq("dit"),
"<tag><tag>co",'n',"tent</tag></tag>",
"<tag><tag>",'<',"/tag></tag>");

checkCommand(forKeySeq("dit"),
"<tag><% jsp",' ',"%></tag>",
"<tag>",'<',"/tag>");

checkCommand(forKeySeq("dit"),
"<tag var=\"<%=jsp%>\"> ",' ',"foo</tag>",
"<tag var=\"<%=jsp%>\">",'<',"/tag>");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ public class XmlTagDelimitedText implements DelimitedText {
//regex usually stops at newlines but open tags might have
//multiple lines of attributes. So, include newlines in search.
//Skip comments (<!-- foo -->), empty-element tags (<foo/>), and jsp (<% %>)
private static final String XML_TAG_REGEX = "<([^<!%]|\n)*?[^/]>";
private static final String XML_TAG_REGEX = "<(?:(?!%|!))[^<]*?(?:(?<!%|/))>";
private static final Pattern tagPattern = Pattern.compile(XML_TAG_REGEX, Pattern.DOTALL);

private static final Pattern tagPattern = Pattern.compile(XML_TAG_REGEX);

private static final String XML_TAG_NAME_REGEX = "([^ \n\t]*)";
private static final String XML_PARAMETERS_REGEX = "(\n|.)*";
private static final String XML_NAME_REGEX = "</?" + XML_TAG_NAME_REGEX + XML_PARAMETERS_REGEX + ">";

private static final Pattern tagNamePattern = Pattern.compile(XML_NAME_REGEX);
private static final String XML_NAME_REGEX = "</?([^\\s]*).*?>";
private static final Pattern tagNamePattern = Pattern.compile(XML_NAME_REGEX, Pattern.DOTALL);

private TextRange endTag;
private TextRange openTag;
Expand Down

0 comments on commit 2b753e0

Please sign in to comment.