Skip to content

Commit

Permalink
Fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jan 27, 2025
1 parent 7ce5522 commit faa5a23
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
uses: AButler/upload-release-assets@v3.0
with:
files: 'build/libs/*.jar;!build/libs/*-sources.jar;!build/libs/*-dev.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ org.gradle.jvmargs=-Xmx1G
fabric_version=0.75.1+1.19.4

# Mod Properties
mod_version = 2.1.0+1.19.4
mod_version = 2.1.1+1.19.4
maven_group = eu.pb4
archives_base_name = placeholder-api

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public TextNode[] parseNodes(TextNode input) {
if (input instanceof LiteralNode literalNode) {
var list = new ArrayList<SubNode<?>>();
parseLiteral(literalNode, list::add);
return parseSubNodes(list.listIterator(), null, -1, false);
return parseSubNodes(list.listIterator(), null, -1);
} else if (input instanceof TranslatedNode translatedNode) {
var list = new ArrayList<>();
for (var arg : translatedNode.args()) {
Expand All @@ -95,7 +95,7 @@ public TextNode[] parseNodes(TextNode input) {
list.add(new SubNode<>(SubNodeType.TEXT_NODE, TextNode.asSingle(parseNodes(children))));
}
}
return new TextNode[]{parentTextNode.copyWith(parseSubNodes(list.listIterator(), null, -1, false), this)};
return new TextNode[]{parentTextNode.copyWith(parseSubNodes(list.listIterator(), null, -1), this)};
} else {
return new TextNode[]{input};
}
Expand All @@ -109,9 +109,7 @@ private void parseLiteral(LiteralNode literalNode, Consumer<SubNode<?>> consumer
var i = reader.read();
if (i == '\\' && reader.canRead()) {
var next = reader.read();
//if (next != '~' && next != '`' && next != '_' && next != '*' && next != '|') {
builder.append(i);
//}
builder.append(next);
continue;
}
Expand All @@ -137,7 +135,14 @@ private void parseLiteral(LiteralNode literalNode, Consumer<SubNode<?>> consumer
type = switch (i) {
case '`' -> SubNodeType.BACK_TICK;
case '*' -> SubNodeType.STAR;
case '_' -> SubNodeType.FLOOR;
case '_' -> {
if (reader.getCursor() == 1 || !reader.canRead()
|| Character.isWhitespace(reader.peek(-2))
|| Character.isWhitespace(reader.peek())) {
yield SubNodeType.FLOOR;
}
yield null;
}
case '(' -> SubNodeType.BRACKET_OPEN;
case ')' -> SubNodeType.BRACKET_CLOSE;
case '[' -> SubNodeType.SQR_BRACKET_OPEN;
Expand All @@ -163,7 +168,7 @@ private void parseLiteral(LiteralNode literalNode, Consumer<SubNode<?>> consumer
}
}

private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNodeType endAt, int count, boolean requireEmpty) {
private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNodeType endAt, int count) {
var out = new ArrayList<TextNode>();
int startIndex = nodes.nextIndex();
var builder = new StringBuilder();
Expand All @@ -173,16 +178,7 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
if (next.type == endAt) {
int foundCount = 1;

boolean endingOrSpace;
if (requireEmpty && nodes.hasNext()) {
var prev = nodes.next();
endingOrSpace = prev.type != SubNodeType.STRING || ((String) prev.value).startsWith(" ");
nodes.previous();
} else {
endingOrSpace = true;
}

if (foundCount == count && endingOrSpace) {
if (foundCount == count) {
if (!builder.isEmpty()) {
out.add(new LiteralNode(builder.toString()));
}
Expand All @@ -194,7 +190,7 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
while (nodes.hasNext()) {
if (nodes.next().type == endAt) {
if ((++foundCount) == count) {
if (requireEmpty && nodes.hasNext()) {
if (nodes.hasNext()) {
var prev = nodes.next();
nodes.previous();
if (prev.type == SubNodeType.STRING && !((String) prev.value).startsWith(" ")) {
Expand Down Expand Up @@ -228,7 +224,7 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
builder.append((String) next.value);
continue;
} else if (next.type == SubNodeType.BACK_TICK && this.allowedFormatting.contains(MarkdownFormat.QUOTE)) {
var value = parseSubNodes(nodes, next.type, 1, false);
var value = parseSubNodes(nodes, next.type, 1);

if (value != null) {
if (!builder.isEmpty()) {
Expand All @@ -239,7 +235,7 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
continue;
}
} else if (next.type == SubNodeType.SPOILER_LINE && this.allowedFormatting.contains(MarkdownFormat.SPOILER)) {
var value = parseSubNodes(nodes, next.type, 1, false);
var value = parseSubNodes(nodes, next.type, 1);

if (value != null) {
if (!builder.isEmpty()) {
Expand All @@ -250,7 +246,7 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
continue;
}
} else if (next.type == SubNodeType.DOUBLE_WAVY_LINE && this.allowedFormatting.contains(MarkdownFormat.STRIKETHROUGH)) {
var value = parseSubNodes(nodes, next.type, 1, false);
var value = parseSubNodes(nodes, next.type, 1);

if (value != null) {
if (!builder.isEmpty()) {
Expand All @@ -270,7 +266,7 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
if (nexter.type == next.type) {
two = true;
var i = nodes.nextIndex();
var value = parseSubNodes(nodes, next.type, 2, false);
var value = parseSubNodes(nodes, next.type, 2);

if (value != null) {
if (!builder.isEmpty()) {
Expand All @@ -296,7 +292,7 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
}

if (startingOrSpace) {
var value = parseSubNodes(nodes, next.type, 1, next.type == SubNodeType.FLOOR);
var value = parseSubNodes(nodes, next.type, 1);

if (value != null) {
if (!builder.isEmpty()) {
Expand All @@ -310,14 +306,14 @@ private TextNode[] parseSubNodes(ListIterator<SubNode<?>> nodes, @Nullable SubNo
}
} else if (next.type == SubNodeType.SQR_BRACKET_OPEN && this.allowedFormatting.contains(MarkdownFormat.URL) && nodes.hasNext()) {
var start = nodes.nextIndex();
var value = parseSubNodes(nodes, SubNodeType.SQR_BRACKET_CLOSE, 1, false);
var value = parseSubNodes(nodes, SubNodeType.SQR_BRACKET_CLOSE, 1);

if (value != null) {
if (nodes.hasNext()) {
var check = nodes.next().type == SubNodeType.BRACKET_OPEN;

if (check) {
var url = parseSubNodes(nodes, SubNodeType.BRACKET_CLOSE, 1, false);
var url = parseSubNodes(nodes, SubNodeType.BRACKET_CLOSE, 1);
if (url != null) {
if (!builder.isEmpty()) {
out.add(new LiteralNode(builder.toString()));
Expand Down

0 comments on commit faa5a23

Please sign in to comment.