Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 31010e4

Browse filesBrowse files
authored
fix: search does not find the contents of the table (docsifyjs#1198)
* fix: search does not find the contents of the table * refactor: add getTableData function
1 parent 6026357 commit 31010e4
Copy full SHA for 31010e4

1 file changed

+14-9Lines changed: 14 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/plugins/search/search.js‎

Copy file name to clipboardExpand all lines: src/plugins/search/search.js
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ function getAllPaths(router) {
5454
return paths;
5555
}
5656

57+
function getTableData(token) {
58+
if (!token.text && token.type === 'table') {
59+
token.text = token.cells
60+
.map(function(rows) {
61+
return rows.join(' | ');
62+
})
63+
.join(' |\n ');
64+
}
65+
return token.text;
66+
}
67+
5768
function saveData(maxAge, expireKey, indexKey) {
5869
localStorage.setItem(expireKey, Date.now() + maxAge);
5970
localStorage.setItem(indexKey, JSON.stringify(INDEXS));
@@ -84,17 +95,11 @@ export function genIndex(path, content = '', router, depth) {
8495
if (!index[slug]) {
8596
index[slug] = { slug, title: '', body: '' };
8697
} else if (index[slug].body) {
98+
token.text = getTableData(token);
99+
87100
index[slug].body += '\n' + (token.text || '');
88101
} else {
89-
if (!token.text) {
90-
if (token.type === 'table') {
91-
token.text = token.cells
92-
.map(function(rows) {
93-
return rows.join(' | ');
94-
})
95-
.join(' |\n ');
96-
}
97-
}
102+
token.text = getTableData(token);
98103

99104
index[slug].body = index[slug].body
100105
? index[slug].body + token.text

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.