diff --git a/website/assets/js/pages/osquery-table-details.page.js b/website/assets/js/pages/osquery-table-details.page.js index 6dc9375f84..50801481af 100644 --- a/website/assets/js/pages/osquery-table-details.page.js +++ b/website/assets/js/pages/osquery-table-details.page.js @@ -45,18 +45,27 @@ parasails.registerPage('osquery-table-details', { if(this.tableToDisplay.keywordsForSyntaxHighlighting){ keywordsForThisTable = this.tableToDisplay.keywordsForSyntaxHighlighting; } + keywordsForThisTable = keywordsForThisTable.sort((a,b)=>{// Sorting the array of keywords by length to match larger keywords first. + if(a.length > b.length){ + return -1; + } + }); (()=>{ $('pre code').each((i, block) => { - window.hljs.highlightBlock(block); - }); - $('.hljs').each((i, el)=>{ - let keywordsInExample = _.filter(keywordsForThisTable, (word)=>{ - return _.includes(_.words(el.innerText, /[^, ]+/g), word); - }); - for(let keyword of keywordsInExample) { - let replacementHMTL = el.innerHTML.replaceAll(keyword, ''+keyword+''); - $(el).html(replacementHMTL); + let keywordsToHighlight = [];// Empty array to track the keywords that we will need to highlight + for(let keyword of keywordsForThisTable){// Going through the array of keywords for this table, if the entire word matches, we'll add it to the + for(let match of block.innerHTML.match(keyword)||[]){ + keywordsToHighlight.push(match); + } } + // Now iterate through the keywordsToHighlight, replacing all matches in the elements innerHTML. + let replacementHMTL = block.innerHTML; + for(let keywordInExample of keywordsToHighlight) { + replacementHMTL = replacementHMTL.replaceAll(keywordInExample, ''+keywordInExample+''); + } + $(block).html(replacementHMTL); + // After we've highlighted our keywords, we'll highlight the rest of the codeblock + window.hljs.highlightBlock(block); }); // Adding [purpose="line-break"] to SQL keywords if they are one of: SELECT, WHERE, FROM, JOIN. (case-insensitive) $('.hljs-keyword').each((i, el)=>{ diff --git a/website/assets/styles/pages/osquery-table-details.less b/website/assets/styles/pages/osquery-table-details.less index 455ac0a960..83cc55255c 100644 --- a/website/assets/styles/pages/osquery-table-details.less +++ b/website/assets/styles/pages/osquery-table-details.less @@ -113,6 +113,20 @@ overflow-y: scroll; overflow-x: show; } + [purpose='evented-table-icon'] { + margin-left: 4px; + padding: 4px 8px; + background-color: @core-vibrant-blue-15; + border-radius: 4px; + display: inline-block; + line-height: 14px; + vertical-align: middle; + img { + height: 14px; + width: 14px; + display: inline-block; + } + } [purpose='table-container'] { height: min-content; } @@ -209,6 +223,9 @@ content: '\a'; } .hljs-attr { // For table and column names + .hljs-keyword { + color: #FFF; + } color: #FFF; background-color: #AE6DDF; border-radius: 4px; diff --git a/website/views/pages/osquery-table-details.ejs b/website/views/pages/osquery-table-details.ejs index bc3c414b91..fc10582777 100644 --- a/website/views/pages/osquery-table-details.ejs +++ b/website/views/pages/osquery-table-details.ejs @@ -41,7 +41,7 @@
@@ -59,7 +59,7 @@