Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Parser Engine Changes:

Language Improvements:

- enh(python) Exclude parens from functions params (#2490) [Álvaro Mondéjar][]
- enh(swift) Add `compactMap` to keywords as built_in (#2478) [Omid Golparvar][]
- enh(nim) adds `func` keyword (#2468) [Adnan Yaqoob][]
- enh(xml) deprecate ActionScript inside script tags (#2444) [Josh Goebel][]
Expand Down Expand Up @@ -70,6 +71,7 @@ Developer Tools:
[Josh Goebel]: https://github.com/yyyc514
[Sean Williams]: https://github.com/hmmwhatsthisdo
[Adnan Yaqoob]: https://github.com/adnanyaqoobvirk
[Álvaro Mondéjar]: https://github.com/mondeja


## Version 9.18.1
Expand Down Expand Up @@ -2148,4 +2150,3 @@ your comments and question to [highlight.js forum][forum]. And don't be afraid
if you find there some fancy Cyrillic letters -- it's for Russian users too :-)

[forum]: http://softwaremaniacs.org/forum/viewforum.php?id=6

10 changes: 8 additions & 2 deletions src/languages/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,14 @@ export default function(hljs) {
};
var PARAMS = {
className: 'params',
begin: /\(/, end: /\)/,
contains: ['self', PROMPT, NUMBER, STRING, hljs.HASH_COMMENT_MODE]
variants: [
// Exclude params at functions without params
{begin: /\(\s*\)/, skip: true, className: null },
{
begin: /\(/, end: /\)/, excludeBegin: true, excludeEnd: true,
contains: ['self', PROMPT, NUMBER, STRING, hljs.HASH_COMMENT_MODE],
},
],
};
SUBST.contains = [STRING, NUMBER, PROMPT];
return {
Expand Down
2 changes: 1 addition & 1 deletion test/markup/python-repl/sample.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ foo = 42"
<span class="hljs-meta">&gt;&gt;&gt;</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">&gt;&gt;&gt;</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">&gt;&gt;&gt;</span> <span class="python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">test</span>():</span></span>
<span class="hljs-meta">...</span> <span class="python"> <span class="hljs-keyword">pass</span></span>
<span class="hljs-meta">&gt;&gt;&gt;</span>
<span class="hljs-meta">&gt;&gt;&gt;</span>
10 changes: 5 additions & 5 deletions test/markup/python/function-header-comments.expect.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">foo</span><span class="hljs-params">(
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">foo</span>(<span class="hljs-params">
bar, <span class="hljs-comment"># commment</span>
)</span>:</span>
</span>):</span>
<span class="hljs-keyword">pass</span>


<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Foo</span><span class="hljs-params">(collections.namedtuple<span class="hljs-params">(<span class="hljs-string">'Test'</span>)</span>, <span class="hljs-params">(
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Foo</span>(<span class="hljs-params">collections.namedtuple(<span class="hljs-params"><span class="hljs-string">'Test'</span></span>), (<span class="hljs-params">
<span class="hljs-string">'name'</span>, <span class="hljs-comment"># comment</span>
)</span>)</span>:</span>
<span class="hljs-keyword">pass</span>
</span>)</span>):</span>
<span class="hljs-keyword">pass</span>
2 changes: 1 addition & 1 deletion test/markup/python/function-header.expect.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(x: int)</span> -&gt; <span class="hljs-keyword">None</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span>(<span class="hljs-params">x: int</span>) -&gt; <span class="hljs-keyword">None</span>:</span>
<span class="hljs-keyword">pass</span>
2 changes: 1 addition & 1 deletion test/markup/python/matrix-multiplication.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">C</span>:</span>

<span class="hljs-meta"> @decorator</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span><span class="hljs-params">(self, H, V, beta, r)</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span>(<span class="hljs-params">self, H, V, beta, r</span>):</span>
S = (H @ beta - r).T @ inv(H @ V @ H.T) @ (H @ beta - r)
<span class="hljs-keyword">return</span> S