Skip to content

Commit 13441eb

Browse files
silverwindevanlucas
authored andcommitted
tools: add table parsing capability to the doctool
PR-URL: #9532 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 9250f02 commit 13441eb

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

tools/doc/html.js

+25-3
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,35 @@ function analyticsScript(analytics) {
162162
`;
163163
}
164164

165+
// replace placeholders in text tokens
166+
function replaceInText(text) {
167+
return linkJsTypeDocs(linkManPages(text));
168+
}
169+
165170
// handle general body-text replacements
166171
// for example, link man page references to the actual page
167172
function parseText(lexed) {
168173
lexed.forEach(function(tok) {
169-
if (tok.text && tok.type !== 'code') {
170-
tok.text = linkManPages(tok.text);
171-
tok.text = linkJsTypeDocs(tok.text);
174+
if (tok.type === 'table') {
175+
if (tok.cells) {
176+
tok.cells.forEach((row, x) => {
177+
row.forEach((_, y) => {
178+
if (tok.cells[x] && tok.cells[x][y]) {
179+
tok.cells[x][y] = replaceInText(tok.cells[x][y]);
180+
}
181+
});
182+
});
183+
}
184+
185+
if (tok.header) {
186+
tok.header.forEach((_, i) => {
187+
if (tok.header[i]) {
188+
tok.header[i] = replaceInText(tok.header[i]);
189+
}
190+
});
191+
}
192+
} else if (tok.text && tok.type !== 'code') {
193+
tok.text = replaceInText(tok.text);
172194
}
173195
});
174196
}

0 commit comments

Comments
 (0)