From d75405fcd858d7cf87f0155ea66ddd5db4b6b52d Mon Sep 17 00:00:00 2001 From: Willy Hardy Date: Thu, 18 Apr 2019 09:47:02 -0400 Subject: [PATCH 1/2] create tableString --- src/plugins/search/search.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 4f14ecd78..9c910b9aa 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -68,6 +68,14 @@ export function genIndex(path, content = '', router, depth) { index[slug] = {slug, title: '', body: ''} } else if (index[slug].body) { index[slug].body += '\n' + (token.text || '') + } else if (token.type === 'table'){ + var tableString = '|'; + token.cells.forEach(function (rows) { + rows.forEach(function(cell) { + tableString += ' ' + cell + ' |'; + }); + }); + index[slug].body = tableString; } else { index[slug].body = token.text } From 1b9710aa6df742aa92b0a6f8e2b1bcbb3537e1be Mon Sep 17 00:00:00 2001 From: Willy Hardy Date: Wed, 24 Apr 2019 09:40:53 -0400 Subject: [PATCH 2/2] use map and join instead of foreach --- src/plugins/search/search.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 9c910b9aa..c4db4cf3a 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -69,12 +69,9 @@ export function genIndex(path, content = '', router, depth) { } else if (index[slug].body) { index[slug].body += '\n' + (token.text || '') } else if (token.type === 'table'){ - var tableString = '|'; - token.cells.forEach(function (rows) { - rows.forEach(function(cell) { - tableString += ' ' + cell + ' |'; - }); - }); + var tableString = token.cells.map(function (rows) { + return rows.join(' | '); + }).join(' |\n '); index[slug].body = tableString; } else { index[slug].body = token.text