Skip to content

Commit

Permalink
Merge 7343888 into 0b6765b
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Jul 25, 2022
2 parents 0b6765b + 7343888 commit d6dae73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ describe('unicode', () => {
.toBe("[string]'34'[clear]")
})

it('alphanumeric', () => {
expect(hlUni('(f1)'))
.toBe('[bracket]([clear]f1[bracket])[clear]')
})

it('functions', () => {
expect(hlUni('COUNT(`id`)'))
.toBe('[function]COUNT[clear][bracket]([clear][string]`id`[clear][bracket])[clear]')
Expand Down Expand Up @@ -132,6 +137,11 @@ describe('html', () => {
.toBe("<span class=\"sql-hl-string\">'34'</span>")
})

it('alphanumeric', () => {
expect(hlHtml('(f1)'))
.toBe('<span class="sql-hl-bracket">(</span>f1<span class="sql-hl-bracket">)</span>')
})

it('functions', () => {
expect(hlHtml('COUNT(`id`)'))
.toBe('<span class="sql-hl-function">COUNT</span><span class="sql-hl-bracket">(</span><span class="sql-hl-string">`id`</span><span class="sql-hl-bracket">)</span>')
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const highlighters = [
},
{
name: 'number',
regex: /(\d+(?:\.\d+)?)/g
regex: /((?<![a-zA-z])\d+(?:\.\d+)?)/g
},
{
name: 'string',
Expand Down
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ console.log(highlight("SELECT COUNT(id), `id`, `username` FROM `users` WHERE `em
console.log(highlight('SELECT id FROM users'))

console.log(highlight('WITH t1 AS (SELECT data_point FROM tablename) SELECT data_point FROM t1;'))
console.log(highlight('SELECT f1, f20b, f3a, -1, 1, "1", 1.00 FROM t1;'))

console.log(highlight('SELECT id FROM listings WHERE status = \'not available\''))
console.log(highlight('SELECT id FROM listings WHERE status = "not available"'))

0 comments on commit d6dae73

Please sign in to comment.