Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Add support for php without opening tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Harrington committed Aug 13, 2018
1 parent 6808f36 commit 9a2b25a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/syntax-highlighter/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require('codemirror/mode/ruby/ruby');
require('codemirror/mode/python/python');
require('codemirror/mode/clike/clike');
require('codemirror/mode/htmlmixed/htmlmixed');
require('codemirror/mode/php/php');

function esc(str) {
return str.replace(/[<&]/g, ch => (ch === '&' ? '&amp;' : '&lt;'));
Expand Down Expand Up @@ -44,6 +45,7 @@ const modes = {
kotlin: ['clike', 'text/x-kotlin'],
liquid: 'htmlmixed',
scss: 'css',
php: ['php', 'text/x-php'],
};

function getMode(lang) {
Expand Down
4 changes: 4 additions & 0 deletions packages/syntax-highlighter/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ test('should work for html', () => {
);
});

test('should work for php without opening tag', () => {
expect(syntaxHighlighter('echo "Hello World";', 'php')).toContain('cm-keyword');
});

test('should work for kotlin', () => {
expect(syntaxHighlighter('println("$index: $element")', 'kotlin')).toContain('cm-variable');
});

0 comments on commit 9a2b25a

Please sign in to comment.