(maybe) Fix bug

This commit is contained in:
syuilo 2017-02-28 21:00:59 +09:00
parent 75a7ad9dae
commit e915b46c65
2 changed files with 14 additions and 1 deletions

View file

@ -189,6 +189,7 @@ const elements = [
} }
if (thisIsNotARegexp) return null; if (thisIsNotARegexp) return null;
if (regexp == '') return null;
if (regexp[0] == ' ' && regexp[regexp.length - 1] == ' ') return null; if (regexp[0] == ' ' && regexp[regexp.length - 1] == ' ') return null;
return { return {

View file

@ -5,7 +5,7 @@
const assert = require('assert'); const assert = require('assert');
const analyze = require('../src/common/text'); 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', () => { describe('Text', () => {
it('is correctly analyzed', () => { it('is correctly analyzed', () => {
@ -59,4 +59,16 @@ describe('Text', () => {
assert.equal(tokens[0].type, 'inline-code'); assert.equal(tokens[0].type, 'inline-code');
assert.equal(tokens[0].content, '`var x = "Strawberry Pasta";`'); assert.equal(tokens[0].content, '`var x = "Strawberry Pasta";`');
}); });
describe('syntax highlighting', () => {
it('regexp', () => {
const html = syntaxhighlighter('/.*/');
assert.equal(html, '<span class="regexp">/.*/</span>');
});
it('slash', () => {
const html = syntaxhighlighter('/');
assert.equal(html, '<span class="symbol">/</span>');
});
});
}); });