@redpanda-data/docs-extensions-and-macros 3.0.11 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.adoc
CHANGED
|
@@ -40,7 +40,7 @@ npm i @redpanda-data/docs-extensions-and-macros
|
|
|
40
40
|
|
|
41
41
|
To use the development version instead, refer to the <<development-quickstart,Development Quickstart>>.
|
|
42
42
|
|
|
43
|
-
== Extensions
|
|
43
|
+
== Antora Extensions
|
|
44
44
|
|
|
45
45
|
This section documents the Antora extensions that are provided by this library and how to configure them.
|
|
46
46
|
|
|
@@ -170,6 +170,24 @@ antora:
|
|
|
170
170
|
unlistedPagesHeading: 'Additional Resources'
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
+
== Asciidoc Extensions
|
|
174
|
+
|
|
175
|
+
This section documents the Asciidoc extensions that are provided by this library and how to configure them.
|
|
176
|
+
|
|
177
|
+
IMPORTANT: Be sure to register each extension under the `asciidoc.extensions` key in the playbook, not the `antora.extensions` key.
|
|
178
|
+
|
|
179
|
+
=== Add line numbers and highlights
|
|
180
|
+
|
|
181
|
+
This extension adds the necessary classes to make line numbers and line highlighting work with Prism.js.
|
|
182
|
+
|
|
183
|
+
==== Registration example
|
|
184
|
+
|
|
185
|
+
```yaml
|
|
186
|
+
antora:
|
|
187
|
+
extensions:
|
|
188
|
+
- '@redpanda-data/docs-extensions-and-macros/asciidoc-extensions/add-line-numbers-highlights'
|
|
189
|
+
```
|
|
190
|
+
|
|
173
191
|
== Macros
|
|
174
192
|
|
|
175
193
|
This section documents the Asciidoc macros that are provided by this library and how to configure them.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function addLineNumbersAndCodeHighlightingAttributes() {
|
|
2
|
+
this.process((doc) => {
|
|
3
|
+
for (const listingBlock of doc.findBy({ context: 'listing' })) {
|
|
4
|
+
const attributes = listingBlock.getAttributes();
|
|
5
|
+
|
|
6
|
+
// Iterate through all attributes of the listing block
|
|
7
|
+
for (let key in attributes) {
|
|
8
|
+
if (key.startsWith('lines')) {
|
|
9
|
+
let newRoleValue = `${key}-${attributes[key]}`;
|
|
10
|
+
|
|
11
|
+
if (attributes.role) {
|
|
12
|
+
if (!attributes.role.includes('line-numbers')) {
|
|
13
|
+
newRoleValue += ' line-numbers';
|
|
14
|
+
}
|
|
15
|
+
listingBlock.setAttribute('role', attributes.role + ' ' + newRoleValue);
|
|
16
|
+
} else {
|
|
17
|
+
newRoleValue += ' line-numbers';
|
|
18
|
+
listingBlock.setAttribute('role', newRoleValue);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function register(registry, { file }) {
|
|
27
|
+
registry.treeProcessor(addLineNumbersAndCodeHighlightingAttributes)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports.register = register;
|
|
@@ -111,8 +111,8 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
|
|
|
111
111
|
// handle titles
|
|
112
112
|
const h1 = article.querySelector('h1')
|
|
113
113
|
if (!h1) {
|
|
114
|
-
logger.
|
|
115
|
-
|
|
114
|
+
logger.warn(`No H1 in ${page.pub.url}...skipping`)
|
|
115
|
+
continue
|
|
116
116
|
}
|
|
117
117
|
const documentTitle = h1.text
|
|
118
118
|
h1.remove()
|
|
@@ -12,7 +12,6 @@ module.exports.register = function ({ config }) {
|
|
|
12
12
|
for (const attachment of attachments) {
|
|
13
13
|
let contentString = attachment['_contents'].toString('utf8');
|
|
14
14
|
if (!asciidoc.attributes) continue
|
|
15
|
-
if (!asciidoc.attributes.hasOwnProperty('replace-attributes-in-attachments')) continue;
|
|
16
15
|
for (const key in asciidoc.attributes) {
|
|
17
16
|
const placeholder = "{" + key + "}";
|
|
18
17
|
const sanitizedValue = sanitizeAttributeValue(asciidoc.attributes[key]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redpanda-data/docs-extensions-and-macros",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.13",
|
|
4
4
|
"description": "Antora extensions and macros developed for Redpanda documentation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antora",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
}
|
|
24
24
|
],
|
|
25
25
|
"exports": {
|
|
26
|
+
"./asciidoc-extensions/add-line-numbers-highlights": {
|
|
27
|
+
"require": "./asciidoc-extensions/add-line-numbers-highlights.js"
|
|
28
|
+
},
|
|
26
29
|
"./extensions/unlisted-pages": {
|
|
27
30
|
"require": "./extensions/unlisted-pages.js"
|
|
28
31
|
},
|
|
@@ -37,6 +40,7 @@
|
|
|
37
40
|
},
|
|
38
41
|
"files": [
|
|
39
42
|
"extensions",
|
|
43
|
+
"asciidoc-extensions",
|
|
40
44
|
"macros"
|
|
41
45
|
],
|
|
42
46
|
"license": "ISC",
|