Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C/C++: Comment improvement #2229

Merged
merged 1 commit into from
Feb 24, 2020
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
4 changes: 4 additions & 0 deletions components/prism-c.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Prism.languages.c = Prism.languages.extend('clike', {
'comment': {
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
greedy: true
},
'class-name': {
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+/,
lookbehind: true
Expand Down
2 changes: 1 addition & 1 deletion components/prism-c.min.js

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

26 changes: 26 additions & 0 deletions tests/languages/c/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// comment
// the comment \
continues!

/**/
/*
* comment
*/

/* open-ended comment

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

[
["comment", "//"],
["comment", "// comment"],
["comment", "// the comment \\\r\n continues!"],
["comment", "/**/"],
["comment", "/*\r\n * comment\r\n */"],
["comment", "/* open-ended comment"]
]

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

Checks for comments.
26 changes: 26 additions & 0 deletions tests/languages/cpp/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// comment
// the comment \
continues!

/**/
/*
* comment
*/

/* open-ended comment

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

[
["comment", "//"],
["comment", "// comment"],
["comment", "// the comment \\\r\n continues!"],
["comment", "/**/"],
["comment", "/*\r\n * comment\r\n */"],
["comment", "/* open-ended comment"]
]

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

Checks for comments.
26 changes: 26 additions & 0 deletions tests/languages/objectivec/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// comment
// the comment \
continues!

/**/
/*
* comment
*/

/* open-ended comment

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

[
["comment", "//"],
["comment", "// comment"],
["comment", "// the comment \\\r\n continues!"],
["comment", "/**/"],
["comment", "/*\r\n * comment\r\n */"],
["comment", "/* open-ended comment"]
]

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

Checks for comments.