Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(javascript) Added node-repl for Node.js REPL sessions #2792

Merged
merged 3 commits into from Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.txt
Expand Up @@ -305,3 +305,4 @@ Contributors:
- Jonathan Sharpe <mail@jonrshar.pe>
- Michael Rush <michaelrush@gmail.com>
- Florian Bezdeka <florian@bezdeka.de>
- Marat Nagayev <nagaevmt@yandex.ru>
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -8,6 +8,7 @@ Parser:
New Languages:

- Added Chapel grammar to SUPPORTED_LANGUAGES (#2806) [Brad Chamberlain][]
- enh(javascript) Added `javascript-repl` for Javascript NodeJS REPL sessions

Language Improvements:

Expand Down
30 changes: 30 additions & 0 deletions src/languages/javascript-repl.js
@@ -0,0 +1,30 @@
/*
Language: JavaScript REPL
Requires: javascript.js
Author: Marat Nagayev <nagaevmt@yandex.ru>
Category: common
*/

export default function(hljs) {
return {
name: 'JavaScript REPL',
contains: [
joshgoebel marked this conversation as resolved.
Show resolved Hide resolved
{
className: 'meta',
starts: {
// a space separates the REPL prefix from the actual code
// this is purely for cleaner HTML output
end: / |$/,
starts: {
end: '$', subLanguage: 'javascript'
}
},
variants: [
{ begin: /^>(?=[ ]|$)/ },
{ begin: /^\.\.\.(?=[ ]|$)/ }
]
},
]
}
}

4 changes: 4 additions & 0 deletions test/detect/javascript-repl/default.txt
@@ -0,0 +1,4 @@
> a = "1"
'1'
> function b(){
... return 1+2;
10 changes: 10 additions & 0 deletions test/markup/javascript-repl/sample.expect.txt
@@ -0,0 +1,10 @@
<span class="hljs-meta">&gt;</span> <span class="javascript"><span class="hljs-keyword">for</span>(<span class="hljs-keyword">let</span> i=<span class="hljs-number">0</span>;i&lt;<span class="hljs-number">5</span>;i++){</span>
<span class="hljs-meta">...</span> <span class="javascript"><span class="hljs-built_in">console</span>.log(i);</span>
<span class="hljs-meta">...</span> <span class="javascript">}</span>
0
1
2
3
4
undefined
<span class="hljs-meta">&gt;</span>
10 changes: 10 additions & 0 deletions test/markup/javascript-repl/sample.txt
@@ -0,0 +1,10 @@
> for(let i=0;i<5;i++){
... console.log(i);
... }
0
1
2
3
4
undefined
>