Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/testing/custom-highlighters.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,40 @@ FROM books
| SORT book_no
| LIMIT 5;
```

## Painless

```painless
int i = (int)5L;
Map m = new HashMap();
HashMap hm = (HashMap)m;
```

```painless
ZonedDateTime zdt1 =
ZonedDateTime.of(1983, 10, 13, 22, 15, 30, 0, ZoneId.of('Z'));
ZonedDateTime zdt2 =
ZonedDateTime.of(1983, 10, 17, 22, 15, 35, 0, ZoneId.of('Z'));

if (zdt1.isAfter(zdt2)) {
// handle condition
}
```

```painless
if (doc.containsKey('start') && doc.containsKey('end')) {

if (doc['start'].size() > 0 && doc['end'].size() > 0) {

ZonedDateTime start = doc['start'].value;
ZonedDateTime end = doc['end'].value;
long differenceInMillis = ChronoUnit.MILLIS.between(start, end);

// handle difference in times
} else {
// handle fields without values
}
} else {
// handle index with missing fields
}
```
26 changes: 26 additions & 0 deletions src/Elastic.Markdown/Assets/hljs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,32 @@ hljs.registerLanguage('eql', function() {
}
})

hljs.registerLanguage('painless', function() {
return {
case_insensitive: true, // language is case-insensitive
keywords: {
keyword: 'where sequence sample untill and or not in in~',
literal: ['false','true','null'],
'subst': 'add between cidrMatch concat divide endsWith indexOf length modulo multiply number startsWith string stringContains substring subtract'
},
contains: [
hljs.QUOTE_STRING_MODE,
hljs.C_LINE_COMMENT_MODE,
{
scope: "operator", // (pathname: path1/path2/dothis) color #ab5656
match: /(?:<|<=|==|:|!=|>=|>|like~?|regex~?)/,
},
{
scope: "punctuation", // (pathname: path1/path2/dothis) color #ab5656
match: /(?:!?\[|\]|\|)/,
},
NUMBER,

]
}
})


hljs.registerLanguage('esql', function() {
return {
case_insensitive: true, // language is case-insensitive
Expand Down
13 changes: 9 additions & 4 deletions src/Elastic.Markdown/Assets/markdown/code.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,21 @@

.hljs-meta,
.hljs-name,
.hljs-type,
.hljs-symbol,
.hljs-bullet,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable {
color: var(--color-yellow-50)
}

.hljs-type,
.hljs-symbol {
color: var(--color-teal-50)
}
.hljs-variable {
color: var(--color-purple-50)
}

.hljs-comment,
.hljs-quote,
.hljs-deletion {
Expand Down Expand Up @@ -155,7 +160,7 @@
color: var(--color-pink-50)
}
.hljs-number {
color: var(--color-teal-50)
color: var(--color-red-50)
}

.hljs-emphasis {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public override bool Close(BlockProcessor processor, Block block)
"console-response" => "json",
"console-result" => "json",
"terminal" => "bash",
"painless" => "java",
_ => codeBlock.Language
};
if (!string.IsNullOrEmpty(codeBlock.Language) && !CodeBlock.Languages.Contains(codeBlock.Language))
Expand Down