Skip to content

Commit 0584aeb

Browse files
committed
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 d33b3d1 commit 0584aeb

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

tools/doc/html.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,35 @@ function analyticsScript(analytics) {
183183
`;
184184
}
185185

186+
// replace placeholders in text tokens
187+
function replaceInText(text) {
188+
return linkJsTypeDocs(linkManPages(text));
189+
}
190+
186191
// handle general body-text replacements
187192
// for example, link man page references to the actual page
188193
function parseText(lexed) {
189194
lexed.forEach(function(tok) {
190-
if (tok.text && tok.type !== 'code') {
191-
tok.text = linkManPages(tok.text);
192-
tok.text = linkJsTypeDocs(tok.text);
195+
if (tok.type === 'table') {
196+
if (tok.cells) {
197+
tok.cells.forEach((row, x) => {
198+
row.forEach((_, y) => {
199+
if (tok.cells[x] && tok.cells[x][y]) {
200+
tok.cells[x][y] = replaceInText(tok.cells[x][y]);
201+
}
202+
});
203+
});
204+
}
205+
206+
if (tok.header) {
207+
tok.header.forEach((_, i) => {
208+
if (tok.header[i]) {
209+
tok.header[i] = replaceInText(tok.header[i]);
210+
}
211+
});
212+
}
213+
} else if (tok.text && tok.type !== 'code') {
214+
tok.text = replaceInText(tok.text);
193215
}
194216
});
195217
}

0 commit comments

Comments
 (0)