From e915b46c65ef392876ce58a6c096f1c306af4c66 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Feb 2017 21:00:59 +0900 Subject: [PATCH] (maybe) Fix bug --- src/common/text/core/syntax-highlighter.js | 1 + test/text.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/common/text/core/syntax-highlighter.js b/src/common/text/core/syntax-highlighter.js index 61237daf62..06c59777e7 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 19f652576b..64247953bf 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, '/'); + }); + }); });