-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(python) Added
python-repl
for Python REPL sessions (#2413)
- Loading branch information
1 parent
48a3ba9
commit 83996aa
Showing
5 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
New languages: | ||
|
||
- none. | ||
- enh(python) Added `python-repl` for Python REPL sessions | ||
|
||
New themes: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Language: Python REPL | ||
Requires: python.js | ||
Author: Josh Goebel <hello@joshgoebel.com> | ||
Category: common | ||
*/ | ||
|
||
export default function(hljs) { | ||
return { | ||
aliases: ['pycon'], | ||
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: 'python' | ||
} | ||
}, | ||
variants: [ | ||
{ begin: /^>>>(?=[ ]|$)/ }, | ||
{ begin: /^\.\.\.(?=[ ]|$)/ } | ||
] | ||
}, | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
>>> v = "foo = 42" | ||
>>> v | ||
"foo = 42" | ||
>>> print(v) | ||
foo = 42 | ||
>>> print(repr(v).rstrip('"')) | ||
"foo = 42 | ||
>>> print(repr(v).lstrip('"')) | ||
foo = 42" | ||
|
||
>>> """ | ||
... abc | ||
... """ | ||
>>> def test(): | ||
... pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<span class="hljs-meta">>>></span> <span class="python">v = <span class="hljs-string">"foo = 42"</span></span> | ||
<span class="hljs-meta">>>></span> <span class="python">v</span> | ||
"foo = 42" | ||
<span class="hljs-meta">>>></span> <span class="python">print(v)</span> | ||
foo = 42 | ||
<span class="hljs-meta">>>></span> <span class="python">print(repr(v).rstrip(<span class="hljs-string">'"'</span>))</span> | ||
"foo = 42 | ||
<span class="hljs-meta">>>></span> <span class="python">print(repr(v).lstrip(<span class="hljs-string">'"'</span>))</span> | ||
foo = 42" | ||
|
||
<span class="hljs-meta">>>></span> <span class="python"><span class="hljs-string">"""</span></span> | ||
<span class="hljs-meta">...</span> <span class="python"><span class="hljs-string">abc</span></span> | ||
<span class="hljs-meta">...</span> <span class="python"><span class="hljs-string">"""</span></span> | ||
<span class="hljs-meta">>>></span> <span class="python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">test</span><span class="hljs-params">()</span>:</span></span> | ||
<span class="hljs-meta">...</span> <span class="python"> <span class="hljs-keyword">pass</span></span> | ||
<span class="hljs-meta">>>></span> | ||
<span class="hljs-meta">>>></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
>>> v = "foo = 42" | ||
>>> v | ||
"foo = 42" | ||
>>> print(v) | ||
foo = 42 | ||
>>> print(repr(v).rstrip('"')) | ||
"foo = 42 | ||
>>> print(repr(v).lstrip('"')) | ||
foo = 42" | ||
|
||
>>> """ | ||
... abc | ||
... """ | ||
>>> def test(): | ||
... pass | ||
>>> | ||
>>> |