Skip to content

Commit 21abe89

Browse files
authored
Merge pull request #3840 from vespa-engine/vadim/native-ranking-list-table-replacement
Tables Fix: Convert NativeRank reference page tables to lists
2 parents 76d6c3f + 90d3354 commit 21abe89

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

en/reference/nativerank.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,9 @@ <h2 id="variables">Variables</h2>
866866
<p>
867867
This is a list of the common variables used in the formulas above:
868868
</p>
869-
<table class="table">
869+
870+
<!--table-to-list-->
871+
<table class="table" id="nativerank-variables-table">
870872
<thead>
871873
<tr><th>Variable</th><th>Description</th></tr>
872874
</thead><tbody>
@@ -915,7 +917,8 @@ <h2 id="configuration-properties">Configuration properties</h2>
915917
<p>
916918
This is a comprehensive list of all the configuration properties to all native rank features:
917919
</p>
918-
<table class="table">
920+
<!--table-to-list-->
921+
<table class="table" id="native-rank-parameters-table">
919922
<thead>
920923
<tr><th>Feature</th><th>Parameter</th><th>Default</th><th>Description</th></tr>
921924
</thead><tbody>

js/table-list-converter.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,63 @@ $(window).on('load', function() {
4040

4141
$table.replaceWith($list);
4242
});
43+
44+
/* Natve Ranking Tables */
45+
$(window).on('load', function() {
46+
let $table = $('#nativerank-variables-table');
47+
let $list = $('<ul id="variable-list"></ul>');
48+
49+
$table.find('tbody tr').each(function() {
50+
let $row = $(this);
51+
let $tds = $row.find('td');
52+
53+
if ($tds.length >= 2) {
54+
let variable = $tds.eq(0).html().trim(); // Keep HTML (e.g., <em>, <sub>)
55+
let description = $tds.eq(1).html().trim(); // Keep inner HTML
56+
57+
let $li = $('<li style="margin-bottom: 1em;"></li>');
58+
$li.append('<strong>' + variable + '</strong>');
59+
$li.append('<div>' + description + '</div>');
60+
61+
$list.append($li);
62+
}
63+
});
64+
65+
$table.replaceWith($list);
66+
});
67+
68+
$(window).on('load', function() {
69+
let $table = $('#native-rank-parameters-table');
70+
let $list = $('<ul id="native-rank-parameters-list"></ul>');
71+
72+
$table.find('tbody tr').each(function() {
73+
let $row = $(this);
74+
let $tds = $row.find('td');
75+
76+
// Skip rows that span all columns (e.g., deprecated notice)
77+
if ($tds.length === 1 && $tds.attr('colspan') === '4') {
78+
let noticeHtml = $tds.html().trim();
79+
let $li = $('<li style="list-style: none; margin: 1em 0; color: red;"></li>');
80+
$li.html(noticeHtml);
81+
$list.append($li);
82+
return;
83+
}
84+
85+
if ($tds.length >= 4) {
86+
let feature = $tds.eq(0).html().trim(); // Feature name (keep HTML)
87+
let parameter = $tds.eq(1).html().trim(); // Parameter (keep HTML)
88+
let defaultValue = $tds.eq(2).text().trim(); // Default (plain text)
89+
let description = $tds.eq(3).html().trim(); // Description (keep HTML)
90+
91+
let $li = $('<li style="margin-bottom: 1em;"></li>');
92+
$li.append('<strong>' + feature + ' → ' + parameter + '</strong>');
93+
$li.append('<div><em>Default:</em> ' + defaultValue + '</div>');
94+
$li.append('<div>' + description + '</div>');
95+
96+
$list.append($li);
97+
}
98+
});
99+
100+
$table.replaceWith($list);
101+
});
102+

0 commit comments

Comments
 (0)