From 57f4d7aa916cfdb710ec406dd0c9c58ea4521c70 Mon Sep 17 00:00:00 2001 From: Brian Dupuis Date: Tue, 27 Jul 2021 16:52:47 -0400 Subject: [PATCH] Addresses issue #8 Only `matchGrammar` on non-empty strings. Also added a maven publish setup for easier publishing to maven local for testing. --- prism4j/build.gradle | 13 +++++++++++++ .../src/main/java/io/noties/prism4j/Prism4j.java | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/prism4j/build.gradle b/prism4j/build.gradle index 5ac2eeb..187797c 100644 --- a/prism4j/build.gradle +++ b/prism4j/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'java-library' +apply plugin: 'maven-publish' version = VERSION_NAME @@ -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 + } + } +} \ No newline at end of file diff --git a/prism4j/src/main/java/io/noties/prism4j/Prism4j.java b/prism4j/src/main/java/io/noties/prism4j/Prism4j.java index 4196ec2..db30b09 100644 --- a/prism4j/src/main/java/io/noties/prism4j/Prism4j.java +++ b/prism4j/src/main/java/io/noties/prism4j/Prism4j.java @@ -182,7 +182,9 @@ public Prism4j(@NotNull GrammarLocator grammarLocator) { public List tokenize(@NotNull String text, @NotNull Grammar grammar) { final List 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; }