diff --git a/docs/reference/esql/functions/binary.asciidoc b/docs/reference/esql/functions/binary.asciidoc index 6148385a8b9f5..32e97b7316d84 100644 --- a/docs/reference/esql/functions/binary.asciidoc +++ b/docs/reference/esql/functions/binary.asciidoc @@ -15,3 +15,6 @@ And these mathematical operators are supported: [.text-center] image::esql/functions/signature/add.svg[Embedded,opts=inline] + +[.text-center] +image::esql/functions/signature/sub.svg[Embedded,opts=inline] diff --git a/docs/reference/esql/functions/signature/add.svg b/docs/reference/esql/functions/signature/add.svg index 62e116d4409c7..10d89efc65f3b 100644 --- a/docs/reference/esql/functions/signature/add.svg +++ b/docs/reference/esql/functions/signature/add.svg @@ -1 +1 @@ -lhs+rhs \ No newline at end of file +lhs+rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/div.svg b/docs/reference/esql/functions/signature/div.svg index 43bf542dcefe5..ea061ae6ef625 100644 --- a/docs/reference/esql/functions/signature/div.svg +++ b/docs/reference/esql/functions/signature/div.svg @@ -1 +1 @@ -lhs/rhs \ No newline at end of file +lhs/rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/equals.svg b/docs/reference/esql/functions/signature/equals.svg index c59fa055877dd..ade4b1260128f 100644 --- a/docs/reference/esql/functions/signature/equals.svg +++ b/docs/reference/esql/functions/signature/equals.svg @@ -1 +1 @@ -lhs==rhs \ No newline at end of file +lhs==rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/greater_than.svg b/docs/reference/esql/functions/signature/greater_than.svg index a49133a438e06..f5eb082d14642 100644 --- a/docs/reference/esql/functions/signature/greater_than.svg +++ b/docs/reference/esql/functions/signature/greater_than.svg @@ -1 +1 @@ -lhs>rhs \ No newline at end of file +lhs>rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/less_than.svg b/docs/reference/esql/functions/signature/less_than.svg index f736ad31f33c1..9858a17450f60 100644 --- a/docs/reference/esql/functions/signature/less_than.svg +++ b/docs/reference/esql/functions/signature/less_than.svg @@ -1 +1 @@ -lhs<rhs \ No newline at end of file +lhs<rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/mod.svg b/docs/reference/esql/functions/signature/mod.svg index 9f07e9724ef2c..20a134a26f232 100644 --- a/docs/reference/esql/functions/signature/mod.svg +++ b/docs/reference/esql/functions/signature/mod.svg @@ -1 +1 @@ -lhs%rhs \ No newline at end of file +lhs%rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/mul.svg b/docs/reference/esql/functions/signature/mul.svg index 435cc2c3ae8cd..b15c488eb874b 100644 --- a/docs/reference/esql/functions/signature/mul.svg +++ b/docs/reference/esql/functions/signature/mul.svg @@ -1 +1 @@ -lhs*rhs \ No newline at end of file +lhs*rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/neg.svg b/docs/reference/esql/functions/signature/neg.svg index 5d0169550098c..6090a85310684 100644 --- a/docs/reference/esql/functions/signature/neg.svg +++ b/docs/reference/esql/functions/signature/neg.svg @@ -1 +1 @@ --v \ No newline at end of file +-v \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/not_equals.svg b/docs/reference/esql/functions/signature/not_equals.svg index b81fbd0ad409f..d4808abbac5a5 100644 --- a/docs/reference/esql/functions/signature/not_equals.svg +++ b/docs/reference/esql/functions/signature/not_equals.svg @@ -1 +1 @@ -lhs!=rhs \ No newline at end of file +lhs!=rhs \ No newline at end of file diff --git a/docs/reference/esql/functions/signature/sub.svg b/docs/reference/esql/functions/signature/sub.svg index 324212e9590cf..8d49ad6b0ac1e 100644 --- a/docs/reference/esql/functions/signature/sub.svg +++ b/docs/reference/esql/functions/signature/sub.svg @@ -1 +1 @@ -lhs-rhs \ No newline at end of file +lhs-rhs \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java index 180fdaaa51c93..d6501568a85ec 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java @@ -113,13 +113,18 @@ private static String toSvg(Expression exp) throws IOException { * on all clients. */ private static String tightenStyles(String svg) { - return svg.replace(".c", "#guide .c").replace(".k", "#guide .k").replace(".s", "#guide .s"); + for (String c : new String[] { "c", "k", "s", "j", "l" }) { + svg = svg.replace("." + c, "#guide ." + c); + } + return svg; } /** * Like a literal but with light grey text for a more muted appearance for syntax. */ private static class Syntax extends Literal { + private static final String LITERAL_CLASS = "l"; + private static final String SYNTAX_CLASS = "lsyn"; private static final String LITERAL_TEXT_CLASS = "j"; private static final String SYNTAX_TEXT_CLASS = "syn"; private static final String SYNTAX_GREY = "8D8D8D"; @@ -133,13 +138,20 @@ private Syntax(String text) { @Override protected RRElement toRRElement(GrammarToRRDiagram grammarToRRDiagram) { - // This performs a monumentally rude hack to replace the text color of this element. + /* + * This performs a monumentally rude hack to replace the text color of this element. + * It renders a "literal" element but intercepts the layer that defines it's css class + * and replaces it with our own. + */ return new RRText(RRText.Type.LITERAL, text, null) { @Override protected void toSVG(RRDiagramToSVG rrDiagramToSVG, int xOffset, int yOffset, RRDiagram.SvgContent svgContent) { super.toSVG(rrDiagramToSVG, xOffset, yOffset, new RRDiagram.SvgContent() { @Override public String getDefinedCSSClass(String style) { + if (style.equals(LITERAL_CLASS)) { + return svgContent.getDefinedCSSClass(SYNTAX_CLASS); + } if (style.equals(LITERAL_TEXT_CLASS)) { return svgContent.getDefinedCSSClass(SYNTAX_TEXT_CLASS); } @@ -148,11 +160,18 @@ public String getDefinedCSSClass(String style) { @Override public String setCSSClass(String cssClass, String definition) { - if (false == cssClass.equals(LITERAL_TEXT_CLASS)) { - return svgContent.setCSSClass(cssClass, definition); + if (cssClass.equals(LITERAL_CLASS)) { + svgContent.setCSSClass(cssClass, definition); + return svgContent.setCSSClass(SYNTAX_CLASS, definition); + } + if (cssClass.equals(LITERAL_TEXT_CLASS)) { + svgContent.setCSSClass(cssClass, definition); + return svgContent.setCSSClass( + SYNTAX_TEXT_CLASS, + definition.replace("fill:#000000", "fill:#" + SYNTAX_GREY) + ); } - svgContent.setCSSClass(cssClass, definition); - return svgContent.setCSSClass(SYNTAX_TEXT_CLASS, definition.replace("fill:#000000", "fill:#" + SYNTAX_GREY)); + return svgContent.setCSSClass(cssClass, definition); } @Override