diff --git a/src/common/text/core/syntax-highlighter.js b/src/common/text/core/syntax-highlighter.js index 61237daf6..06c59777e 100644 --- a/src/common/text/core/syntax-highlighter.js +++ b/src/common/text/core/syntax-highlighter.js @@ -189,6 +189,7 @@ const elements = [ } if (thisIsNotARegexp) return null; + if (regexp == '') return null; if (regexp[0] == ' ' && regexp[regexp.length - 1] == ' ') return null; return { diff --git a/test/text.ts b/test/text.ts index 19f652576..64247953b 100644 --- a/test/text.ts +++ b/test/text.ts @@ -5,7 +5,7 @@ const assert = require('assert'); const analyze = require('../src/common/text'); -//const compile = require('../src/web/app/common/scripts/text-compiler'); +const syntaxhighlighter = require('../src/common/text/core/syntax-highlighter'); describe('Text', () => { it('is correctly analyzed', () => { @@ -59,4 +59,16 @@ describe('Text', () => { assert.equal(tokens[0].type, 'inline-code'); assert.equal(tokens[0].content, '`var x = "Strawberry Pasta";`'); }); + + describe('syntax highlighting', () => { + it('regexp', () => { + const html = syntaxhighlighter('/.*/'); + assert.equal(html, '/.*/'); + }); + + it('slash', () => { + const html = syntaxhighlighter('/'); + assert.equal(html, '/'); + }); + }); });