Skip to content

Commit

Permalink
Merge pull request highlightjs#647 from suever/matlab_block_comments
Browse files Browse the repository at this point in the history
Adds support for multi-line comments in Matlab
  • Loading branch information
Sannis committed Nov 19, 2014
2 parents 27de0d1 + d13c6fc commit a9b4a75
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/languages/matlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ function(hljs) {
relevance: 0,
starts: TRANSPOSE
},
{
// Block comment
className: 'comment',
begin: '^\\s*\\%\\{\\s*$', end: '^\\s*\\%\\}\\s*$'
},
{
className: 'comment',
begin: '\\%', end: '$'
Expand Down
4 changes: 4 additions & 0 deletions test/detect/matlab/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ while(max(len) > 2 * min(len))
points = [ points(1:i, :); [xm, ym]; points(i + 1:end, :)];
end

%{
This is a block comment. Please ignore me.
%}

function [net] = get_fit_network(inputs, targets)
% Create Network
numHiddenNeurons = 20; % Adjust as desired
Expand Down
27 changes: 27 additions & 0 deletions test/markup/matlab/block_comment.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<span class="hljs-comment">%{ evaluate_this = false; % Evaluated as regular single-line comment</span>
evaluate_this = true;
<span class="hljs-comment">%}</span>

evaluate_this = true;
<span class="hljs-comment">
%{
This is a multi-line comment
evaluate_this = false;
%{
%}
</span>
evaluate_this = true;
<span class="hljs-comment">
%{
Opening (%{) and closing (%}) block comment markers can be within a comment block
%}
</span>
evaluate_this = true;
<span class="hljs-comment">
%{
Indented block comments can be indented
or not
and whitespace can be added before or after the %{ and %}
%}
</span>
evaluate_this = true;
27 changes: 27 additions & 0 deletions test/markup/matlab/block_comment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%{ evaluate_this = false; % Evaluated as regular single-line comment
evaluate_this = true;
%}

evaluate_this = true;

%{
This is a multi-line comment
evaluate_this = false;
%{
%}

evaluate_this = true;

%{
Opening (%{) and closing (%}) block comment markers can be within a comment block
%}

evaluate_this = true;

%{
Indented block comments can be indented
or not
and whitespace can be added before or after the %{ and %}
%}

evaluate_this = true;

0 comments on commit a9b4a75

Please sign in to comment.