Skip to content

Commit

Permalink
Addresses issue noties#8
Browse files Browse the repository at this point in the history
Only `matchGrammar` on non-empty strings. Also added a maven publish setup for easier publishing to maven local for testing.
  • Loading branch information
bjdupuis committed Jul 27, 2021
1 parent 75ac3da commit 57f4d7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions prism4j/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'java-library'
apply plugin: 'maven-publish'

version = VERSION_NAME

Expand All @@ -20,3 +21,15 @@ if (project.hasProperty('release')) {
}
apply from: 'https://raw.githubusercontent.com/noties/gradle-mvn-push/master/gradle-mvn-push-jar.gradle'
}

publishing {
publications {
maven(MavenPublication) {
def libraryFile = file("build/libs/prism4j-${version}.jar")
groupId "io.noties"
artifactId 'prism4j'
version version
artifact libraryFile
}
}
}
4 changes: 3 additions & 1 deletion prism4j/src/main/java/io/noties/prism4j/Prism4j.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ public Prism4j(@NotNull GrammarLocator grammarLocator) {
public List<Node> tokenize(@NotNull String text, @NotNull Grammar grammar) {
final List<Node> entries = new ArrayList<>(3);
entries.add(new TextImpl(text));
matchGrammar(text, entries, grammar, 0, 0, false, null);
if (text.length() > 0) {
matchGrammar(text, entries, grammar, 0, 0, false, null);
}
return entries;
}

Expand Down

0 comments on commit 57f4d7a

Please sign in to comment.