Skip to content

Commit

Permalink
enh(javascript) Added node-repl for Node.js REPL sessions (#2792)
Browse files Browse the repository at this point in the history
  • Loading branch information
nagayev committed Nov 11, 2020
1 parent 760dcd6 commit 435f6c6
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.txt
Expand Up @@ -305,5 +305,6 @@ Contributors:
- Jonathan Sharpe <mail@jonrshar.pe>
- Michael Rush <michaelrush@gmail.com>
- Florian Bezdeka <florian@bezdeka.de>
- Marat Nagayev <nagaevmt@yandex.ru>
- Patrick Scheibe <patrick@halirutan.de>
- Kyle Brown <kylebrown9@github>
4 changes: 3 additions & 1 deletion CHANGES.md
Expand Up @@ -7,7 +7,8 @@ Parser:

New Languages:

- Added Chapel grammar to SUPPORTED_LANGUAGES (#2806) [Brad Chamberlain][]
- Added 3rd party Chapel grammar to SUPPORTED_LANGUAGES (#2806) [Brad Chamberlain][]
- enh(javascript) Added `node-repl` for Node.js REPL sessions (#2792) [Marat Nagayev][]

Language Improvements:

Expand Down Expand Up @@ -43,6 +44,7 @@ New themes:
- *StackOverflow Dark* by [Jan Pilzer][]
- *StackOverflow Light* by [Jan Pilzer][]

[Marat Nagayev]: https://github.com/nagayev
[Fredrik Ekre]: https://github.com/fredrikekre
[Richard Gibson]: https://github.com/gibson042
[Josh Goebel]: https://github.com/joshgoebel
Expand Down
30 changes: 30 additions & 0 deletions src/languages/node-repl.js
@@ -0,0 +1,30 @@
/*
Language: Node REPL
Requires: javascript.js
Author: Marat Nagayev <nagaevmt@yandex.ru>
Category: scripting
*/

/** @type LanguageFn */
export default function(hljs) {
return {
name: 'Node REPL',
contains: [
{
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/node-repl/default.txt
@@ -0,0 +1,4 @@
> a = "1"
'1'
> function b(){
... return 1+2;
10 changes: 10 additions & 0 deletions test/markup/node-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/node-repl/sample.txt
@@ -0,0 +1,10 @@
> for(let i=0;i<5;i++){
... console.log(i);
... }
0
1
2
3
4
undefined
>

0 comments on commit 435f6c6

Please sign in to comment.