@redpanda-data/docs-extensions-and-macros 3.6.4 → 3.6.6

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.
@@ -27,6 +27,11 @@ module.exports.register = function (registry, config = {}) {
27
27
 
28
28
  const terms = termFiles.map(file => {
29
29
  const content = file.contents.toString()
30
+ // Split content by lines and get the first non-empty line as the title
31
+ const lines = content.split('\n').map(line => line.trim())
32
+ const firstNonEmptyLine = lines.find(line => line.length > 0)
33
+ // Remove leading '=' characters (AsciiDoc syntax) and trim whitespace
34
+ const pageTitle = firstNonEmptyLine ? firstNonEmptyLine.replace(/^=+\s*/, '') : '#'
30
35
  const attributes = {}
31
36
 
32
37
  let match
@@ -50,6 +55,7 @@ module.exports.register = function (registry, config = {}) {
50
55
  term: attributes['term-name'],
51
56
  def: attributes['hover-text'],
52
57
  category: attributes['category'] || '',
58
+ pageTitle,
53
59
  content
54
60
  }
55
61
 
@@ -76,13 +82,16 @@ module.exports.register = function (registry, config = {}) {
76
82
  }
77
83
  }
78
84
 
79
- //characters to replace by '-' in generated idprefix
80
- const IDRX = /[/ _.-]+/g
85
+ // Characters to replace by '-' in generated idprefix
86
+ const IDRX = /[\/ _.-]+/g
81
87
 
82
- function termId (term) {
83
- return term.toLowerCase().replace(IDRX, '-')
88
+ function termId(term) {
89
+ // Remove brackets before replacing other characters
90
+ const noBracketsTerm = term.replace(/[\[\]\(\)]/g, '') // Remove brackets
91
+ return noBracketsTerm.toLowerCase().replace(IDRX, '-')
84
92
  }
85
93
 
94
+
86
95
  const TRX = /(<[a-z]+)([^>]*>.*)/
87
96
 
88
97
  function glossaryInlineMacro () {
@@ -91,7 +100,7 @@ module.exports.register = function (registry, config = {}) {
91
100
  self.named('glossterm')
92
101
  //Specifying the regexp allows spaces in the term.
93
102
  self.$option('regexp', /glossterm:([^[]+)\[(|.*?[^\\])\]/)
94
- self.positionalAttributes(['definition', 'customText']);
103
+ self.positionalAttributes(['definition', 'customText']); // Allows for specifying custom link text
95
104
  self.process(function (parent, target, attributes) {
96
105
  const term = attributes.term || target
97
106
  const customText = attributes.customText || term;
@@ -110,9 +119,11 @@ module.exports.register = function (registry, config = {}) {
110
119
  }
111
120
  const logTerms = document.hasAttribute('glossary-log-terms')
112
121
  var definition;
122
+ var pageTitle;
113
123
  const index = context.gloss.findIndex((candidate) => candidate.term === term)
114
124
  if (index >= 0) {
115
125
  definition = context.gloss[index].def
126
+ pageTitle = context.gloss[index].pageTitle
116
127
  } else {
117
128
  definition = attributes.definition;
118
129
  }
@@ -138,7 +149,7 @@ module.exports.register = function (registry, config = {}) {
138
149
  if ((termExistsInContext && links) || (links && customLink)) {
139
150
  inline = customLink
140
151
  ? self.createInline(parent, 'anchor', customText, { type: 'link', target: customLink, attributes: { ...attrs, window: '_blank', rel: 'noopener noreferrer' } })
141
- : self.createInline(parent, 'anchor', customText, { type: 'xref', target: `${glossaryPage}#${termId(term)}`, reftext: customText, attributes: attrs })
152
+ : self.createInline(parent, 'anchor', customText, { type: 'xref', target: `${glossaryPage}#${termId(pageTitle)}`, reftext: customText, attributes: attrs })
142
153
  } else {
143
154
  inline = self.createInline(parent, 'quoted', customText, { attributes: attrs })
144
155
  }
@@ -2,16 +2,19 @@
2
2
 
3
3
  module.exports.register = function (registry, context) {
4
4
  function filterComponentTable() {
5
- // Retrieve and standardize filter inputs
6
5
  const nameInput = document.getElementById('componentTableSearch').value.trim().toLowerCase();
7
6
  const typeFilter = Array.from(document.querySelector('#typeFilter').selectedOptions).map(option => option.value);
8
7
 
9
- // Check if the supportFilter element exists
8
+ // Check for the existence of support and enterprise license filters (optional)
10
9
  const supportFilterElement = document.querySelector('#supportFilter');
11
10
  const supportFilter = supportFilterElement
12
11
  ? Array.from(supportFilterElement.selectedOptions).map(option => option.value)
13
12
  : [];
14
13
 
14
+ // Get the 'support=enterprise' query parameter from the URL
15
+ const params = getQueryParams();
16
+ const enterpriseSupportFilter = params.support === 'enterprise'; // Check if 'support=enterprise' is in the URL
17
+
15
18
  const table = document.getElementById('componentTable');
16
19
  const trs = table.getElementsByTagName('tr');
17
20
 
@@ -19,34 +22,26 @@ module.exports.register = function (registry, context) {
19
22
  const row = trs[i];
20
23
  const nameTd = row.querySelector('td[id^="componentName-"]');
21
24
  const typeTd = row.querySelector('td[id^="componentType-"]');
22
- const supportTd = row.querySelector('td[id^="componentSupport-"]');
23
- const typeDropdown = typeTd ? typeTd.querySelector('.type-dropdown') : null;
25
+ const supportTd = row.querySelector('td[id^="componentSupport-"]'); // Support column, if present
26
+ const enterpriseSupportTd = row.querySelector('td[id^="componentLicense-"]'); // Enterprise License column, if present
24
27
 
25
- if (nameTd && typeTd) {
26
- const nameText = nameTd.textContent.trim().toLowerCase();
28
+ if (typeTd) { // Ensure that at least the Type column is present
29
+ const nameText = nameTd ? nameTd.textContent.trim().toLowerCase() : '';
27
30
  const typeText = typeTd.textContent.trim().toLowerCase().split(', ').map(item => item.trim());
28
31
  const supportText = supportTd ? supportTd.textContent.trim().toLowerCase() : '';
32
+ const enterpriseSupportText = enterpriseSupportTd ? enterpriseSupportTd.textContent.trim().toLowerCase() : ''; // Yes or No
29
33
 
30
34
  // Determine if the row should be shown
31
35
  const showRow =
32
- ((!nameInput || nameText.includes(nameInput)) &&
33
- (typeFilter.length === 0 || typeFilter.some(value => typeText.includes(value))) &&
34
- (!supportTd || supportFilter.length === 0 || supportFilter.some(value => supportText.includes(value)))
36
+ ((!nameInput || nameText.includes(nameInput)) && // Filter by name if present
37
+ (typeFilter.length === 0 || typeFilter.some(value => typeText.includes(value))) && // Filter by type
38
+ (!supportTd || supportFilter.length === 0 || supportFilter.some(value => supportText.includes(value))) && // Filter by support if present
39
+ (!enterpriseSupportFilter || !enterpriseSupportTd || supportText.includes('enterprise') || enterpriseSupportText === 'yes') // Filter by enterprise support if 'support=enterprise' is in the URL
35
40
  );
36
41
 
37
42
  row.style.display = showRow ? '' : 'none';
38
-
39
- if (showRow && typeFilter.length > 0 && typeDropdown) {
40
- const matchingOption = Array.from(typeDropdown.options).find(option =>
41
- typeFilter.includes(option.text.toLowerCase())
42
- );
43
- if (matchingOption) {
44
- typeDropdown.value = matchingOption.value;
45
- updateComponentUrl(typeDropdown, false);
46
- }
47
- }
48
43
  } else {
49
- row.style.display = 'none'; // Hide row if essential cells are missing
44
+ row.style.display = 'none'; // Hide row if the Type column is missing
50
45
  }
51
46
  }
52
47
  }
@@ -289,8 +284,9 @@ function generateConnectorsHTMLTable(connectors, isCloud) {
289
284
  const params = {};
290
285
  const searchParams = new URLSearchParams(window.location.search);
291
286
  searchParams.forEach((value, key) => {
292
- params[key] = value;
287
+ params[key] = value.toLowerCase();
293
288
  });
289
+
294
290
  return params;
295
291
  }
296
292
 
@@ -304,24 +300,26 @@ function generateConnectorsHTMLTable(connectors, isCloud) {
304
300
 
305
301
  // Initialize Choices.js for type dropdowns
306
302
  document.addEventListener('DOMContentLoaded', function() {
307
- const params = getQueryParams();
308
- if (params.search) {
309
- document.getElementById('componentTableSearch').value = params.search;
310
- }
311
- if (params.type) {
312
- document.getElementById('typeFilter').value = params.type;
313
- }
314
- if (params.support) {
315
- document.getElementById('supportFilter').value = params.support;
303
+ const params = getQueryParams();
304
+ const search = document.getElementById('componentTableSearch');
305
+ const typeFilter = document.getElementById('typeFilter');
306
+ const supportFilter = document.getElementById('supportFilter');
307
+ if (params.search && search) {
308
+ search.value = params.search;
309
+ }
310
+ if (params.type && typeFilter) {
311
+ typeFilter.value = params.type;
316
312
  }
317
-
318
- filterComponentTable();
319
- const typeDropdowns = document.querySelectorAll('.type-dropdown');
320
- typeDropdowns.forEach(dropdown => {
321
- new Choices(dropdown, {
322
- searchEnabled: false,
323
- allowHTML: true,
324
- removeItemButton: true });
313
+ if (params.support && supportFilter) {
314
+ supportFilter.value = params.support;
315
+ }
316
+ filterComponentTable();
317
+ const typeDropdowns = document.querySelectorAll('.type-dropdown');
318
+ typeDropdowns.forEach(dropdown => {
319
+ new Choices(dropdown, {
320
+ searchEnabled: false,
321
+ allowHTML: true,
322
+ removeItemButton: true });
325
323
  });
326
324
  });
327
325
  </script>`;
@@ -410,4 +408,4 @@ function generateConnectorsHTMLTable(connectors, isCloud) {
410
408
  return self.createBlock(parent, 'pass', typeDropdown + enterpriseAdmonition);
411
409
  });
412
410
  });
413
- };
411
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "3.6.4",
3
+ "version": "3.6.6",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",