diff --git a/aio/tools/transforms/angular-base-package/index.js b/aio/tools/transforms/angular-base-package/index.js index 8c946c89ec..037f52322e 100644 --- a/aio/tools/transforms/angular-base-package/index.js +++ b/aio/tools/transforms/angular-base-package/index.js @@ -66,7 +66,7 @@ module.exports = new Package('angular-base', [ collectExamples.exampleFolders = []; generateKeywordsProcessor.ignoreWords = require(path.resolve(__dirname, 'ignore-words'))['en']; - generateKeywordsProcessor.docTypesToIgnore = ['example-region']; + generateKeywordsProcessor.docTypesToIgnore = [undefined, 'example-region', 'json-doc', 'api-list-data', 'api-list-data', 'contributors-json', 'navigation-json', 'announcements-json']; generateKeywordsProcessor.propertiesToIgnore = ['basePath', 'renderedContent', 'docType', 'searchTitle']; }) diff --git a/aio/tools/transforms/angular-base-package/processors/generateKeywords.js b/aio/tools/transforms/angular-base-package/processors/generateKeywords.js index a1d85e7e5c..d5141d88d1 100644 --- a/aio/tools/transforms/angular-base-package/processors/generateKeywords.js +++ b/aio/tools/transforms/angular-base-package/processors/generateKeywords.js @@ -43,10 +43,10 @@ module.exports = function generateKeywordsProcessor(log) { .filter(doc => !doc.internal && !doc.privateExport); - for(const doc of filteredDocs) { + for (const doc of filteredDocs) { // Search each top level property of the document for search terms let mainTokens = []; - for(const key of Object.keys(doc)) { + for (const key of Object.keys(doc)) { const value = doc[key]; if (isString(value) && !propertiesToIgnore.has(key)) { mainTokens.push(...tokenize(value, ignoreWords, dictionary)); @@ -58,8 +58,8 @@ module.exports = function generateKeywordsProcessor(log) { // Extract all the keywords from the headings let headingTokens = []; if (doc.vFile && doc.vFile.headings) { - for(const headingTag of Object.keys(doc.vFile.headings)) { - for(const headingText of doc.vFile.headings[headingTag]) { + for (const headingTag of Object.keys(doc.vFile.headings)) { + for (const headingText of doc.vFile.headings[headingTag]) { headingTokens.push(...tokenize(headingText, ignoreWords, dictionary)); } } @@ -120,27 +120,37 @@ function isString(value) { function tokenize(text, ignoreWords, dictionary) { // Split on whitespace and things that are likely to be HTML tags (this is not exhaustive but reduces the unwanted tokens that are indexed). - const rawTokens = text.split(/[\s/]+|<\/?[a-z]+(?:\s+\w+(?:="[^"]+")?)*>/img); + const rawTokens = text.split(new RegExp( + '[\\s/]+' + // whitespace + '|' + // or + '?[a-z]+(?:\\s+\\w+(?:="[^"]+")?)*/?>', // simple HTML tags (e.g.