Skip to content

Commit

Permalink
Patch comments in layout files
Browse files Browse the repository at this point in the history
  • Loading branch information
WasabiThumb committed Nov 6, 2024
1 parent c635b9d commit e65b093
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>codes.wasabi</groupId>
<artifactId>xclaim</artifactId>
<version>1.15.0</version>
<version>1.15.1</version>
<packaging>jar</packaging>

<name>XClaim</name>
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/codes/wasabi/xclaim/util/io/XmlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class XmlReader extends FilterReader {
private final StringBuilder buf = new StringBuilder();
private int counter = 0;
private int peeked = -1;
private int commentDashes = 0;

public XmlReader(@NotNull Reader in) {
super(in);
Expand Down Expand Up @@ -96,7 +97,22 @@ protected void setState(@NotNull State state) {
}

protected @Nullable Symbol readSymbolInternal(char c) throws IOException {
// The left angle bracket is a globally special char, let's check it first
if (this.state == State.READ_COMMENT) {
if (this.commentDashes >= 2) {
if (c == '>') {
this.state = State.READ_TXT;
} else if (c != '-') {
this.commentDashes = 0;
}
} else {
if (c == '-') {
this.commentDashes++;
} else {
this.commentDashes = 0;
}
}
return null;
}
if (c == '<') {
if (this.state == State.READ_TXT) {
final Symbol ret = (this.buf.length() == 0) ? null : Symbol.text(this.buf.toString());
Expand All @@ -113,9 +129,6 @@ protected void setState(@NotNull State state) {
return this.readSymbolForTag(c);
case READ_ATTRS:
return this.readSymbolForAttrs(c);
case READ_COMMENT:
if (c == '>') this.state = State.READ_TXT;
break;
}
return null;
}
Expand All @@ -137,6 +150,7 @@ protected void setState(@NotNull State state) {
final boolean initEmpty = this.buf.length() == 0;
if (initEmpty && c == '!') {
// comment
this.commentDashes = 0;
this.state = State.READ_COMMENT;
return null;
}
Expand Down

0 comments on commit e65b093

Please sign in to comment.