Skip to content

Commit

Permalink
Q: Make comments greedy. Update known failures and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Mar 26, 2018
1 parent 0c139d1 commit a0f5081
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
17 changes: 12 additions & 5 deletions components/prism-q.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Prism.languages.q = {
{

pattern: /([\t )\]}])\/.*/,
lookbehind: true
lookbehind: true,
greedy: true
},
// From http://code.kx.com/wiki/Reference/Slash:
// A line which has / as its first character and contains at least one other non-whitespace character is a whole-line comment and is ignored entirely.
Expand All @@ -15,13 +16,19 @@ Prism.languages.q = {
// The / and \ must be the first char on the line, but may be followed by any amount of whitespace.
{
pattern: /(^|\r?\n|\r)\/[\t ]*(?:(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?(?:\\(?=[\t ]*(?:\r?\n|\r))|$)|\S.*)/,
lookbehind: true
lookbehind: true,
greedy: true
},
// From http://code.kx.com/wiki/Reference/Slash:
// A \ on a line by itself with no preceding matching / will comment to end of file.
/^\\[\t ]*(?:\r?\n|\r)[\s\S]+/m,

/^#!.+/m
{
pattern: /^\\[\t ]*(?:\r?\n|\r)[\s\S]+/m,
greedy: true
},
{
pattern: /^#!.+/m,
greedy: true
}
],
'symbol': /`(?::\S+|[\w.]*)/,
'datetime': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-q.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions examples/prism-q.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,5 @@ <h2>Known failures</h2>
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
</p>

<h3>Two double quotes in a comment</h3>
<pre><code>/ This "comment" is broken</code></pre>

<h3>The global context is highlighted as a verb</h3>
<pre><code>\d .</code></pre>
12 changes: 6 additions & 6 deletions tests/languages/q/comment_feature.test
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/usr/bin/env q
/ Foobar
/ Foobar "baz"

/
Foo
bar
bar "baz"
\

\
Foo
Bar
Bar "baz"

----------------------------------------------------

[
["comment", "#!/usr/bin/env q"],
["comment", "/ Foobar"],
["comment", "/\r\nFoo\r\nbar\r\n\\"],
["comment", "\\\r\nFoo\r\nBar"]
["comment", "/ Foobar \"baz\""],
["comment", "/\r\nFoo\r\nbar \"baz\"\r\n\\"],
["comment", "\\\r\nFoo\r\nBar \"baz\""]
]

----------------------------------------------------
Expand Down

0 comments on commit a0f5081

Please sign in to comment.