Skip to content

Commit

Permalink
tools: add table parsing capability to the doctool
Browse files Browse the repository at this point in the history
PR-URL: #9532
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
silverwind committed Apr 19, 2017
1 parent d33b3d1 commit 0584aeb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,35 @@ function analyticsScript(analytics) {
`;
}

// replace placeholders in text tokens
function replaceInText(text) {
return linkJsTypeDocs(linkManPages(text));
}

// handle general body-text replacements
// for example, link man page references to the actual page
function parseText(lexed) {
lexed.forEach(function(tok) {
if (tok.text && tok.type !== 'code') {
tok.text = linkManPages(tok.text);
tok.text = linkJsTypeDocs(tok.text);
if (tok.type === 'table') {
if (tok.cells) {
tok.cells.forEach((row, x) => {
row.forEach((_, y) => {
if (tok.cells[x] && tok.cells[x][y]) {
tok.cells[x][y] = replaceInText(tok.cells[x][y]);
}
});
});
}

if (tok.header) {
tok.header.forEach((_, i) => {
if (tok.header[i]) {
tok.header[i] = replaceInText(tok.header[i]);
}
});
}
} else if (tok.text && tok.type !== 'code') {
tok.text = replaceInText(tok.text);
}
});
}
Expand Down

0 comments on commit 0584aeb

Please sign in to comment.