This is an automated email from the ASF dual-hosted git repository. Cole-Greer pushed a commit to branch docs-3.7 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit e679cfa9eeaee2ebbe0d3a70eaebee5a07425fe6 Author: Cole Greer <[email protected]> AuthorDate: Wed May 27 14:06:43 2026 -0700 Handle triple-quoted strings in statement grouping Multi-line SPARQL queries use triple-quoted strings that span lines without leading whitespace (e.g., WHERE clauses). Track open/close of triple-quote pairs to keep them as single statements. Reduces skipped blocks from 13 to 3. --- .../tinkerpop/gremlin/docs/GremlinTreeprocessor.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java b/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java index b927ca989f..5633adbe51 100644 --- a/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java +++ b/tools/tinkerpop-docs/src/main/java/org/apache/tinkerpop/gremlin/docs/GremlinTreeprocessor.java @@ -509,17 +509,21 @@ public class GremlinTreeprocessor extends Treeprocessor { static List<String> buildStatements(final String[] lines) { final List<String> statements = new ArrayList<>(); final StringBuilder current = new StringBuilder(); + boolean inTripleQuote = false; for (final String line : lines) { final String cleaned = stripCallouts(line); + // Track triple-quote state + final int tqCount = countOccurrences(cleaned, "\"\"\""); if (current.length() == 0) { current.append(cleaned); - } else if (cleaned.length() > 0 && Character.isWhitespace(cleaned.charAt(0))) { + } else if (inTripleQuote || (cleaned.length() > 0 && Character.isWhitespace(cleaned.charAt(0)))) { current.append("\n").append(cleaned); } else { statements.add(current.toString()); current.setLength(0); current.append(cleaned); } + if (tqCount % 2 != 0) inTripleQuote = !inTripleQuote; } if (current.length() > 0) { statements.add(current.toString()); @@ -527,23 +531,33 @@ public class GremlinTreeprocessor extends Treeprocessor { return statements; } + private static int countOccurrences(final String str, final String sub) { + int count = 0; + int idx = 0; + while ((idx = str.indexOf(sub, idx)) != -1) { count++; idx += sub.length(); } + return count; + } + /** * Groups source lines into complete statements for display. Preserves callouts. */ static List<String> buildDisplayStatements(final String[] lines) { final List<String> statements = new ArrayList<>(); final StringBuilder current = new StringBuilder(); + boolean inTripleQuote = false; for (final String line : lines) { final String stripped = stripCallouts(line); + final int tqCount = countOccurrences(stripped, "\"\"\""); if (current.length() == 0) { current.append(line); - } else if (stripped.length() > 0 && Character.isWhitespace(stripped.charAt(0))) { + } else if (inTripleQuote || (stripped.length() > 0 && Character.isWhitespace(stripped.charAt(0)))) { current.append("\n").append(line); } else { statements.add(current.toString()); current.setLength(0); current.append(line); } + if (tqCount % 2 != 0) inTripleQuote = !inTripleQuote; } if (current.length() > 0) { statements.add(current.toString());
