Skip to content

Commit

Permalink
fix(cpp): Allow declaring multiple functions and parenthetical initia…
Browse files Browse the repository at this point in the history
…lizers

Fix highlightjs#3148
  • Loading branch information
edemaine committed Apr 20, 2021
1 parent 7b6df3d commit 59a6e12
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/languages/cpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export default function(hljs) {
end: /[{;=]/,
excludeEnd: true,
keywords: CPP_KEYWORDS,
illegal: /[^\w\s\*&:<>.]/,
illegal: /[^\w\s\*&:<>.,]/,
contains: [
{ // to prevent it from being confused as the function title
begin: DECLTYPE_AUTO_RE,
Expand Down
2 changes: 2 additions & 0 deletions test/markup/cpp/function-declarations.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">A</span><span class="hljs-params">()</span>: a(<span class="hljs-number">10</span>) {</span>}
<span class="hljs-function"><span class="hljs-keyword">explicit</span> <span class="hljs-title">A</span><span class="hljs-params">()</span>: a(<span class="hljs-number">10</span>) {</span>}

<span class="hljs-function"><span class="hljs-keyword">extern</span> <span class="hljs-keyword">void</span> <span class="hljs-title">f</span><span class="hljs-params">(<span class="hljs-keyword">int</span>)</span>, <span class="hljs-title">g</span><span class="hljs-params">(<span class="hljs-keyword">char</span>)</span></span>;
2 changes: 2 additions & 0 deletions test/markup/cpp/function-declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ test();

void A(): a(10) {}
explicit A(): a(10) {}

extern void f(int), g(char);

0 comments on commit 59a6e12

Please sign in to comment.