Skip to content

Commit 00431a9

Browse files
authored
Merge branch 'main' into fix/include-anchors-toc
2 parents f486d5a + d387acc commit 00431a9

40 files changed

+3244
-444
lines changed

.github/workflows/preview-build.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: preview-build
22

33
on:
4-
pull_request_target:
4+
pull_request_target:
55
types:
66
- opened
77
- synchronize
@@ -34,7 +34,7 @@ permissions:
3434

3535
jobs:
3636
build:
37-
concurrency:
37+
concurrency:
3838
group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }}
3939
cancel-in-progress: ${{ github.event_name == 'pull_request_target' }}
4040
runs-on: ubuntu-latest
@@ -46,14 +46,19 @@ jobs:
4646
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6
4747
with:
4848
files: ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}
49-
49+
50+
- name: Free Disk Space
51+
uses: jlumbroso/free-disk-space@main
52+
with:
53+
tool-cache: false
54+
5055
- name: Checkout
5156
if: github.event_name == 'push' || steps.check-files.outputs.any_changed == 'true'
5257
uses: actions/checkout@v4
53-
with:
58+
with:
5459
ref: ${{ github.event.pull_request.head.sha || github.ref }}
5560
persist-credentials: false
56-
61+
5762
- name: Create Deployment
5863
if: github.event_name == 'push' || steps.check-files.outputs.any_changed == 'true'
5964
uses: actions/github-script@v7
@@ -86,7 +91,7 @@ jobs:
8691
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
8792
})
8893
return deployment.data.id
89-
94+
9095
- name: Generate env.PATH_PREFIX
9196
if: steps.deployment.outputs.result
9297
env:
@@ -113,7 +118,7 @@ jobs:
113118
- name: Bootstrap Action Workspace
114119
if: github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result
115120
uses: ./.github/actions/bootstrap
116-
121+
117122
# we run our artifact directly please use the prebuild
118123
# elastic/docs-builder@main GitHub Action for all other repositories!
119124
- name: Build documentation
@@ -142,7 +147,7 @@ jobs:
142147
--paths "${PATH_PREFIX}" "${PATH_PREFIX}/*"
143148
144149
- name: Update Link Index
145-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.s3-upload.outcome == 'success'
150+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.s3-upload.outcome == 'success'
146151
uses: elastic/docs-builder/actions/update-link-index@main
147152

148153
- name: Update deployment status

docs/_docset.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ toc:
6565
- file: comments.md
6666
- file: conditionals.md
6767
- file: dropdowns.md
68+
- file: definition-lists.md
6869
- file: example_blocks.md
6970
- file: file_inclusion.md
7071
- file: frontmatter.md

docs/syntax/definition-lists.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Definition Lists
2+
3+
4+
A Definition List in Markdown is created by writing a term on one line, followed by a colon and at least one space (`: `) on the next line, followed by the definition. Multiple paragraphs in the definition should be indented with spaces to match the definition text.
5+
6+
7+
## Basic definition list
8+
9+
::::{tab-set}
10+
11+
:::{tab-item} Output
12+
13+
Fruit
14+
: A sweet and fleshy product of a tree or other plant that contains seed and can be eaten as food. Common examples include apples, oranges, and bananas. Most fruits are rich in vitamins, minerals and fiber.
15+
16+
Vegetable
17+
: Any edible part of a plant that is used in savory dishes. This includes roots, stems, leaves, flowers, and sometimes fruits that are used as vegetables.
18+
19+
Unlike fruits, vegetables are typically lower in sugar content and higher in fiber. Common examples include carrots, broccoli, spinach, potatoes, and tomatoes (which are technically fruits).
20+
21+
Grain
22+
: The edible seeds or fruit of grass-like plants belonging to the family Poaceae. These include wheat, rice, corn, oats, and barley. See [Types of Grains](https://en.wikipedia.org/wiki/Grain).
23+
24+
Legume
25+
: Plants in the family Fabaceae, or their fruit or seeds, such as peas, beans, lentils and peanuts. See [Common Legumes](https://en.wikipedia.org/wiki/Legume).
26+
27+
:::
28+
29+
:::{tab-item} Markdown
30+
31+
```markdown
32+
Fruit
33+
: A sweet and fleshy product of a tree or other plant that contains seed and can be eaten as food. Common examples include apples, oranges, and bananas. Most fruits are rich in vitamins, minerals and fiber.
34+
35+
Vegetable
36+
: Any edible part of a plant that is used in savory dishes. This includes roots, stems, leaves, flowers, and sometimes fruits that are used as vegetables.
37+
38+
Unlike fruits, vegetables are typically lower in sugar content and higher in fiber. Common examples include carrots, broccoli, spinach, potatoes, and tomatoes (which are technically fruits).
39+
40+
Grain
41+
: The edible seeds or fruit of grass-like plants belonging to the family Poaceae. These include wheat, rice, corn, oats, and barley. See [Types of Grains](https://en.wikipedia.org/wiki/Grain).
42+
43+
Legume
44+
: Plants in the family Fabaceae, or their fruit or seeds, such as peas, beans, lentils and peanuts. See [Common Legumes](https://en.wikipedia.org/wiki/Legume).
45+
```
46+
47+
:::
48+
49+
::::

docs/syntax/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ We support _some_ [GitHub Flavored Markdown (GFM) extensions](https://github.git
6969

7070
### Supported
7171

72-
* [](tables.md#github-flavored-markdown-gfm-table)
72+
* [](tables.md#basic-table)
7373
* Strikethrough: ~~as seen here~~
7474

7575
### Not supported

docs/syntax/tables.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,64 @@ A table is an arrangement of data with rows and columns. Each row consists of ce
66
* a delimiter row separating the header from the data
77
* zero or more data rows
88

9-
## Notes
9+
## Basic Table
1010

11-
* A leading and trailing pipe is recommended for clarity of reading
12-
* Spaces between pipes and cell content are trimmed
13-
* Block-level elements cannot be inserted in a table
11+
::::{tab-set}
1412

15-
## GitHub Flavored Markdown (GFM) Table
16-
17-
You can use the GFM table syntax to create a table:
18-
19-
```
13+
:::{tab-item} Output
2014
| Country | Capital |
2115
| ------- | --------------- |
2216
| USA | Washington D.C. |
2317
| Canada | Ottawa |
24-
```
18+
| Mexico | Mexico City |
19+
| Brazil | Brasília |
20+
| UK | London |
21+
:::
2522

23+
:::{tab-item} Markdown
24+
```markdown
2625
| Country | Capital |
2726
| ------- | --------------- |
2827
| USA | Washington D.C. |
2928
| Canada | Ottawa |
29+
| Mexico | Mexico City |
30+
| Brazil | Brasília |
31+
| UK | London |
32+
:::
33+
34+
::::
35+
36+
:::{note}
37+
38+
* A leading and trailing pipe is recommended for clarity of reading
39+
* Spaces between pipes and cell content are trimmed
40+
* Block-level elements cannot be inserted in a table
41+
42+
:::
43+
44+
45+
## Responsive Table
46+
47+
Every table is responsive by default. The table will automatically scroll horizontally when the content is wider than the viewport.
48+
49+
::::{tab-set}
50+
51+
:::{tab-item} Output
52+
| Product Name | Price ($) | Stock | Category | Rating | Color | Weight (kg) | Warranty (months) |
53+
|--------------|-----------|--------|-----------|---------|----------|-------------|-------------------|
54+
| Laptop Pro | 1299.99 | 45 | Computer | 4.5 | Silver | 1.8 | 24 |
55+
| Smart Watch | 299.99 | 120 | Wearable | 4.2 | Black | 0.045 | 12 |
56+
| Desk Chair | 199.50 | 78 | Furniture | 4.8 | Gray | 12.5 | 36 |
57+
:::
58+
59+
:::{tab-item} Markdown
60+
```markdown
61+
| Product Name | Price ($) | Stock | Category | Rating | Color | Weight (kg) | Warranty (months) |
62+
|--------------|-----------|--------|-----------|---------|----------|-------------|-------------------|
63+
| Laptop Pro | 1299.99 | 45 | Computer | 4.5 | Silver | 1.8 | 24 |
64+
| Smart Watch | 299.99 | 120 | Wearable | 4.2 | Black | 0.045 | 12 |
65+
| Desk Chair | 199.50 | 78 | Furniture | 4.8 | Gray | 12.5 | 36 |
66+
:::
67+
```
68+
69+
::::

docs/syntax/tabs.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ This is where the content for tab #2 goes.
3636

3737
::::
3838

39-
---
4039

4140
## Tab Groups
4241

docs/testing/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ The files in this directory are used for testing purposes. Do not edit these fil
3030
{
3131
"key": "value"
3232
}
33-
```
33+
```

src/Elastic.Markdown/Assets/copybutton.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ const addCopyButtonToCodeCells = () => {
145145
// happens because we load ClipboardJS asynchronously.
146146

147147
// Add copybuttons to all of our code cells
148-
const COPYBUTTON_SELECTOR = 'div.highlight pre';
148+
const COPYBUTTON_SELECTOR = '.markdown-content div.highlight pre';
149149
const codeCells = document.querySelectorAll(COPYBUTTON_SELECTOR)
150150
codeCells.forEach((codeCell, index) => {
151+
if (codeCell.id) {
152+
return
153+
}
154+
151155
const id = codeCellId(index)
152156
codeCell.setAttribute('id', id)
153157

@@ -256,6 +260,5 @@ var copyTargetText = (trigger) => {
256260
}
257261

258262
export function initCopyButton() {
259-
console.log("initCopyButton");
260-
runWhenDOMLoaded(addCopyButtonToCodeCells)
263+
addCopyButtonToCodeCells();
261264
}

src/Elastic.Markdown/Assets/hljs.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ hljs.registerLanguage('esql', function() {
164164

165165
hljs.addPlugin(mergeHTMLPlugin);
166166
export function initHighlight() {
167-
168-
hljs.highlightAll();
167+
document.querySelectorAll('#markdown-content pre code:not(.hljs)').forEach((block) => {
168+
hljs.highlightElement(block);
169+
});
169170
}
Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1+
import "htmx.org"
2+
import "htmx-ext-preload"
13
import {initTocNav} from "./toc-nav";
24
import {initHighlight} from "./hljs";
35
import {initTabs} from "./tabs";
46
import {initCopyButton} from "./copybutton";
7+
import {initNav} from "./pages-nav";
8+
import {$$} from "select-dom"
59

6-
initTocNav();
7-
initHighlight();
8-
initCopyButton();
9-
initTabs();
10+
document.addEventListener('htmx:load', function() {
11+
initTocNav();
12+
initHighlight();
13+
initCopyButton();
14+
initTabs();
15+
initNav();
16+
});
17+
18+
document.body.addEventListener('htmx:oobAfterSwap', function(event) {
19+
if (event.target.id === 'markdown-content') {
20+
window.scrollTo(0, 0);
21+
}
22+
});
23+
24+
document.body.addEventListener('htmx:pushedIntoHistory', function(event) {
25+
const currentNavItem = $$('.current');
26+
currentNavItem.forEach(el => {
27+
el.classList.remove('current');
28+
})
29+
// @ts-ignore
30+
const navItems = $$('a[href="' + event.detail.path + '"]');
31+
navItems.forEach(navItem => {
32+
navItem.classList.add('current');
33+
});
34+
});

0 commit comments

Comments
 (0)