Skip to content

Commit 1c1ab39

Browse files
authored
Merge branch 'main' into feature/applies-to-rework
2 parents b41fa67 + a431832 commit 1c1ab39

File tree

8 files changed

+269
-15
lines changed

8 files changed

+269
-15
lines changed

.github/workflows/preview-build.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
- opened
77
- synchronize
88
- reopened
9-
- labeled
10-
- unlabeled
119
push:
1210
branches:
1311
- main
@@ -114,13 +112,8 @@ jobs:
114112
115113
- name: Bootstrap Action Workspace
116114
if: github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result
117-
118115
uses: ./.github/actions/bootstrap
119116

120-
- name: Set REDESIGN feature flag
121-
if: contains(github.event.pull_request.labels.*.name, 'redesign') && steps.deployment.outputs.result
122-
run: echo "REDESIGN=true" >> $GITHUB_ENV
123-
124117
# we run our artifact directly please use the prebuild
125118
# elastic/docs-builder@main GitHub Action for all other repositories!
126119
- name: Build documentation

docs/testing/custom-highlighters.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ GET /mydocuments/_search
3232
}
3333
```
3434
````
35+
::::
3536

3637
## EQL
3738

@@ -68,4 +69,83 @@ function calls
6869
modulo(10, 6)
6970
modulo(10, 5)
7071
modulo(10, 0.5)
72+
```
73+
74+
75+
76+
## ESQL
77+
78+
79+
```esql
80+
FROM employees
81+
| LIMIT 1000
82+
```
83+
84+
```esql
85+
ROW a = "2023-01-23T12:15:00.000Z - some text - 127.0.0.1"
86+
| DISSECT a """%{date} - %{msg} - %{ip}"""
87+
| KEEP date, msg, ip
88+
```
89+
90+
```esql
91+
FROM books
92+
| WHERE KQL("author: Faulkner")
93+
| KEEP book_no, author
94+
| SORT book_no
95+
| LIMIT 5
96+
```
97+
98+
```esql
99+
FROM hosts
100+
| STATS COUNT_DISTINCT(ip0), COUNT_DISTINCT(ip1)
101+
```
102+
103+
```esql
104+
ROW message = "foo ( bar"
105+
| WHERE message RLIKE "foo \\( bar"
106+
```
107+
108+
```esql
109+
FROM books
110+
| WHERE author:"Faulkner"
111+
| KEEP book_no, author
112+
| SORT book_no
113+
| LIMIT 5;
114+
```
115+
116+
## Painless
117+
118+
```painless
119+
int i = (int)5L;
120+
Map m = new HashMap();
121+
HashMap hm = (HashMap)m;
122+
```
123+
124+
```painless
125+
ZonedDateTime zdt1 =
126+
ZonedDateTime.of(1983, 10, 13, 22, 15, 30, 0, ZoneId.of('Z'));
127+
ZonedDateTime zdt2 =
128+
ZonedDateTime.of(1983, 10, 17, 22, 15, 35, 0, ZoneId.of('Z'));
129+
130+
if (zdt1.isAfter(zdt2)) {
131+
// handle condition
132+
}
133+
```
134+
135+
```painless
136+
if (doc.containsKey('start') && doc.containsKey('end')) {
137+
138+
if (doc['start'].size() > 0 && doc['end'].size() > 0) {
139+
140+
ZonedDateTime start = doc['start'].value;
141+
ZonedDateTime end = doc['end'].value;
142+
long differenceInMillis = ChronoUnit.MILLIS.between(start, end);
143+
144+
// handle difference in times
145+
} else {
146+
// handle fields without values
147+
}
148+
} else {
149+
// handle index with missing fields
150+
}
71151
```

src/Elastic.Markdown/Assets/hljs.ts

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const NUMBER = {
4343
relevance: 0
4444
};
4545

46-
4746
hljs.registerLanguage('eql', function() {
4847
return {
4948
case_insensitive: true, // language is case-insensitive
@@ -69,6 +68,100 @@ hljs.registerLanguage('eql', function() {
6968
}
7069
})
7170

71+
hljs.registerLanguage('painless', function() {
72+
return {
73+
case_insensitive: true, // language is case-insensitive
74+
keywords: {
75+
keyword: 'where sequence sample untill and or not in in~',
76+
literal: ['false','true','null'],
77+
'subst': 'add between cidrMatch concat divide endsWith indexOf length modulo multiply number startsWith string stringContains substring subtract'
78+
},
79+
contains: [
80+
hljs.QUOTE_STRING_MODE,
81+
hljs.C_LINE_COMMENT_MODE,
82+
{
83+
scope: "operator", // (pathname: path1/path2/dothis) color #ab5656
84+
match: /(?:<|<=|==|:|!=|>=|>|like~?|regex~?)/,
85+
},
86+
{
87+
scope: "punctuation", // (pathname: path1/path2/dothis) color #ab5656
88+
match: /(?:!?\[|\]|\|)/,
89+
},
90+
NUMBER,
91+
92+
]
93+
}
94+
})
95+
96+
97+
hljs.registerLanguage('esql', function() {
98+
return {
99+
case_insensitive: true, // language is case-insensitive
100+
keywords: {
101+
keyword: 'FROM ROW SHOW DISSECT DROP ENRICH EVAL GROK KEEP LIMIT RENAME SORT STATS WHERE METADATA',
102+
literal: ['false','true','null'],
103+
function: [
104+
// aggregate
105+
"AVG", "COUNT", "COUNT_DISTINCT", "MAX", "MEDIAN", "MEDIAN_ABSOLUTE_DEVIATION", "MIN",
106+
"PERCENTILE", "SUM", "TOP", "VALUES", "WEIGHTED_AVG", "BUCKET",
107+
108+
// conditional
109+
"CASE", "COALESCE", "GREATEST", "LEAST",
110+
111+
//Date
112+
"DATE_DIFF", "DATE_EXTRACT", "DATE_FORMAT", "DATE_PARSE", "DATE_TRUNC", "NOW",
113+
114+
//ip
115+
"CIDR_MATCH", "IP_PREFIX",
116+
117+
//math
118+
"ABS", "ACOS", "ASIN", "ATAN", "ATAN2", "CBRT", "CEIL", "COS", "COSH", "E", "EXP", "FLOOR",
119+
"HYPOT", "LOG", "LOG10", "PI", "POW", "ROUND", "SIGNUM", "SIN", "SINH", "SQRT", "TAN",
120+
"TANH", "TAU",
121+
122+
//search
123+
"MATCH", "QSTR",
124+
125+
//spatial
126+
"ST_DISTANCE", "ST_INTERSECTS", "ST_DISJOINT", "ST_CONTAINS", "ST_WITHIN", "ST_X", "ST_Y",
127+
128+
//string
129+
130+
"BIT_LENGTH", "BYTE_LENGTH", "CONCAT", "ENDS_WITH", "FROM_BASE64", "LEFT", "LENGTH", "LOCATE",
131+
"LTRIM", "REPEAT", "REPLACE", "REVERSE", "RIGHT", "RTRIM", "SPACE", "SPLIT", "STARTS_WITH",
132+
"SUBSTRING", "TO_BASE64", "TO_LOWER", "TO_UPPER", "TRIM",
133+
134+
//type conversion
135+
"TO_BOOLEAN", "TO_CARTESIANPOINT", "TO_CARTESIANSHAPE", "TO_DATETIME", "TO_DEGREES",
136+
"TO_DOUBLE", "TO_GEOPOINT", "TO_GEOSHAPE", "TO_INTEGER", "TO_IP", "TO_LONG", "TO_RADIANS",
137+
"TO_STRING", "TO_VERSION",
138+
139+
//multivalued
140+
"MV_APPEND", "MV_AVG", "MV_CONCAT", "MV_COUNT", "MV_DEDUPE", "MV_FIRST", "MV_LAST", "MV_MAX",
141+
"MV_MEDIAN", "MV_MEDIAN_ABSOLUTE_DEVIATION", "MV_MIN", "MV_PERCENTILE", "MV_PSERIES_WEIGHTED_SUM",
142+
"MV_SORT", "MV_SLICE", "MV_SUM", "MV_ZIP",
143+
144+
"KQL"
145+
]
146+
},
147+
contains: [
148+
hljs.QUOTE_STRING_MODE,
149+
hljs.C_LINE_COMMENT_MODE,
150+
{
151+
scope: "operator", // (pathname: path1/path2/dothis) color #ab5656
152+
match: /(?:<|<=|==|::|\w+:|!=|>=|>|LIKE|RLIKE|IS NULL|IS NOT NULL)/,
153+
},
154+
{
155+
scope: "punctuation", // (pathname: path1/path2/dothis) color #ab5656
156+
match: /(?:!?\[|\]|\|)/,
157+
},
158+
NUMBER,
159+
160+
]
161+
}
162+
})
163+
164+
72165
hljs.addPlugin(mergeHTMLPlugin);
73166
export function initHighlight() {
74167

src/Elastic.Markdown/Assets/markdown/code.css

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,91 @@
7979
text-decoration: inherit;
8080
font-weight: inherit;
8181
}
82+
83+
84+
.hljs-built_in,
85+
.hljs-selector-tag,
86+
.hljs-section,
87+
.hljs-link {
88+
color: var(--color-blue-elastic-70)
89+
}
90+
91+
.hljs-keyword {
92+
color: var(--color-blue-elastic-70)
93+
}
94+
95+
.hljs {
96+
color: var(--color-blue-elastic-30) !important;
97+
}
98+
.hljs-subst {
99+
color: var(--color-purple-60)
100+
}
101+
.hljs-function {
102+
color: var(--color-purple-60)
103+
}
104+
105+
.hljs-title,
106+
.hljs-title.function,
107+
.hljs-attr,
108+
.hljs-meta-keyword {
109+
color: var(--color-yellow-50)
110+
}
111+
112+
.hljs-string {
113+
color: var(--color-green-50)
114+
}
115+
.hljs-operator {
116+
color: var(--color-yellow-50)
117+
}
118+
119+
.hljs-meta,
120+
.hljs-name,
121+
.hljs-bullet,
122+
.hljs-addition,
123+
.hljs-template-tag,
124+
.hljs-template-variable {
125+
color: var(--color-yellow-50)
126+
}
127+
128+
.hljs-type,
129+
.hljs-symbol {
130+
color: var(--color-teal-50)
131+
}
132+
.hljs-variable {
133+
color: var(--color-purple-50)
134+
}
135+
136+
.hljs-comment,
137+
.hljs-quote,
138+
.hljs-deletion {
139+
color: var(--color-grey-70)
140+
}
141+
142+
.hljs-punctuation {
143+
color: var(--color-grey-50);
144+
font-weight: bold;
145+
}
146+
147+
.hljs-keyword,
148+
.hljs-selector-tag,
149+
.hljs-literal,
150+
.hljs-title,
151+
.hljs-section,
152+
.hljs-doctag,
153+
.hljs-type,
154+
.hljs-name,
155+
.hljs-strong {
156+
font-weight: bold;
157+
}
158+
159+
.hljs-literal {
160+
color: var(--color-pink-50)
161+
}
162+
.hljs-number {
163+
color: var(--color-red-50)
164+
}
165+
166+
.hljs-emphasis {
167+
font-style: italic;
168+
}
82169
}

src/Elastic.Markdown/Assets/styles.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import "tailwindcss";
22
@import "./fonts.css";
33
@import "./theme.css";
4-
@import "highlight.js/styles/github-dark-dimmed.css";
54
@import "./markdown/typography.css";
65
@import "./markdown/list.css";
76
@import "./markdown/tabs.css";

src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public override bool Close(BlockProcessor processor, Block block)
8989
"console-response" => "json",
9090
"console-result" => "json",
9191
"terminal" => "bash",
92+
"painless" => "java",
9293
_ => codeBlock.Language
9394
};
9495
if (!string.IsNullOrEmpty(codeBlock.Language) && !CodeBlock.Languages.Contains(codeBlock.Language))

src/Elastic.Markdown/Myst/CodeBlocks/SupportedLanguages.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ public static class CodeBlock
181181
{ "zephir", "zep" }, // Zephir
182182

183183
//CUSTOM, Elastic language we wrote highlighters for
184-
{ "eql", "" }
184+
{ "eql", "" },
185+
{ "esql", "" }
185186
};
186187

187188

src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<li class="block ml-2 pl-2 border-l-1 border-l-gray-200 group/li @(isCurrent ? "current" : string.Empty)">
1111
<div class="flex">
1212
<a
13-
class="sidebar-link my-1 ml-5 group-[.current]/li:text-blue-elastic! @(isCurrent ? "" : string.Empty)"
13+
class="sidebar-link my-1 ml-5 group-[.current]/li:text-blue-elastic! @(isCurrent ? "pointer-events-none" : string.Empty)"
1414
href="@f.Url"
1515
@(isCurrent ? "aria-current=page" : string.Empty)>
1616
@f.NavigationTitle
@@ -22,12 +22,12 @@
2222
{
2323
var g = folder.Group;
2424
var isCurrent = g.Index == Model.CurrentDocument;
25-
var slug = g.Index?.Title.Slugify();
2625
const int initialExpandLevel = 1;
2726
var containsCurrent = g.HoldsCurrent(Model.CurrentDocument) || g.ContainsCurrentPage(Model.CurrentDocument);
2827
var shouldInitiallyExpand = containsCurrent || g.Depth <= initialExpandLevel;
28+
var uuid = Guid.NewGuid().ToString();
2929
<li class="flex flex-wrap @(g.Depth > 1 ? "ml-2 pl-2 border-l-1 border-l-gray-200" : string.Empty)">
30-
<label for="@slug" class="peer group/label flex items-center overflow-hidden @(g.Depth == 1 ? "mt-2" : "")">
30+
<label for="@uuid" class="peer group/label flex items-center overflow-hidden @(g.Depth == 1 ? "mt-2" : "")">
3131
<svg
3232
xmlns="http://www.w3.org/2000/svg"
3333
fill="none"
@@ -38,7 +38,7 @@
3838
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/>
3939
</svg>
4040
<input
41-
id="@slug"
41+
id="@uuid"
4242
type="checkbox"
4343
class="hidden"
4444
aria-hidden="true"
@@ -47,7 +47,7 @@
4747
>
4848
<a
4949
href="@g.Index?.Url"
50-
class="sidebar-link inline-block my-1 @(g.Depth == 1 ? "uppercase tracking-[0.05em] text-ink-light font-semibold" : string.Empty) @(containsCurrent ? "font-semibold" : string.Empty) @(isCurrent ? "current text-blue-elastic!" : string.Empty)">
50+
class="sidebar-link inline-block my-1 @(g.Depth == 1 ? "uppercase tracking-[0.05em] text-ink-light font-semibold" : string.Empty) @(containsCurrent ? "font-semibold" : string.Empty) @(isCurrent ? "current pointer-events-none text-blue-elastic!" : string.Empty)">
5151
@g.Index?.NavigationTitle
5252
</a>
5353
</label>

0 commit comments

Comments
 (0)