'use strict'; const hljs = require('../../build'); hljs.debugMode(); describe('beginScope and endScope', () => { before(() => { const grammar = function() { return { contains: [ { begin: /xyz/, end: /123/, scope: "string", beginScope: "red", endScope: "green" }, { begin: /123/, end: [ /a/,/((b))/,/c/,/d/ ], endScope: { 1: "apple", 2: "boy", 4: "delta" } }, { begin: /dumb/, end: /luck/, beginScope: "red", endScope: "green" }, { begin: /abc/, beginScope: "letters", contains: [ { match: /def/, scope: "more" } ] } ] } }; hljs.registerLanguage("test", grammar); }); after(() => { hljs.unregisterLanguage("test"); }); it('should support multi-class', () => { const code = "123 abcd"; const result = hljs.highlight(code, { language: 'test' }); result.value.should.equal(`123 abcd`); }) it('should support an outer scope wrapper', () => { const code = "xyz me 123"; const result = hljs.highlight(code, { language: 'test' }); result.value.should.equal( `` + `xyz me 123` + ``); }) it('should support textual beginScope & endScope pair', () => { const code = "dumb really luck"; const result = hljs.highlight(code, { language: 'test' }); result.value.should.equal(`dumb really luck`); }); it('should support textual beginScope', () => { const code = "abcdef"; const result = hljs.highlight(code, { language: 'test' }); result.value.should.equal(`abcdef`); }); });