Skip to content

Commit

Permalink
Fix use of preceding whitespace in comments in Q lexer (#858)
Browse files Browse the repository at this point in the history
If there is more than one space before a single-line comment, the Q
lexer does not tokenise the comment correctly. This commit fixes that
bug.
  • Loading branch information
streetster authored and pyrmont committed Aug 19, 2019
1 parent 59624c1 commit 05d217d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/q.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.builtins
end

# White space and comments
rule(%r{[ \t\r]\/.*$}, Comment::Single)
rule(%r{\s+/.*}, Comment::Single)
rule(/[ \t\r]+/, Text::Whitespace)
rule(%r{^/$.*?^\\$}m, Comment::Multiline)
rule(%r{^\/[^\n]*$(\n[^\S\n]+.*$)*}, Comment::Multiline)
Expand Down
4 changes: 3 additions & 1 deletion spec/visual/samples/q
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ iasc|idesc|inv|keys|load|log|lsq|ltime|ltrim|maxs|md5|meta|mins|next|parse|plist
/ Strings
("";"x\n";"\007")

a:1 2 3 / comment with leading whitespaces
b:3 4 5 5 / to bring in line with this comment

10D 10D10 10D10:10 10D10:10:10 10D10:10:10.11
10Dz 10D10p 10D10:10n 10D10:10:10z 10D10:10:10.11p
Expand Down Expand Up @@ -74,4 +76,4 @@ til eof comment
/
no effect
\
no effect
no effect

0 comments on commit 05d217d

Please sign in to comment.