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
Add operator detecting for c/cpp #3964
Open
TOMWT-qwq
wants to merge
137
commits into
highlightjs:main
Choose a base branch
from
TOMWT-qwq:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 115 commits
Commits
Show all changes
137 commits
Select commit
Hold shift + click to select a range
ae71926
Update cpp.js
TOMWT-qwq 7eb71cd
Update cpp.js
TOMWT-qwq 8b06206
Update cpp.js
TOMWT-qwq c119ef1
Update cpp.js
TOMWT-qwq d321277
Update CHANGES.md
TOMWT-qwq 5f93501
Update CHANGES.md
TOMWT-qwq 2f91b37
Update CHANGES.md
TOMWT-qwq a07c92b
Update cpp.js
TOMWT-qwq 7f99840
Update CHANGES.md
TOMWT-qwq 523b7b5
Update cpp.js
TOMWT-qwq 2a50233
clean up and simply PR
joshgoebel bdd303c
Update cpp.js
TOMWT-qwq 5c0b290
Update cpp.js
TOMWT-qwq d9360e7
Update cpp.js
TOMWT-qwq 1b5949a
Update cpp.js
TOMWT-qwq 349f398
Update cpp.js
TOMWT-qwq 75ba6ee
Update cpp.js
TOMWT-qwq 071577e
Update CHANGES.md
TOMWT-qwq 7d9d5c7
link in regex.escape
joshgoebel d654f38
Update bitwise-keywords.expect.txt
tomwt-awa e958fcc
Update bugs.expect.txt
tomwt-awa 5406e47
Update cpp.js
tomwt-awa e5a8d20
Update expression-keywords.expect.txt
tomwt-awa 12a02fe
Update cpp.js
tomwt-awa 95724ea
Update function-params.expect.txt
tomwt-awa b0c0597
Update cpp.js
tomwt-awa cb5015c
Update cpp.js
tomwt-awa 7f9a622
Update default.expect.txt
tomwt-awa 19d7bae
Update string-literals.expect.txt
tomwt-awa 37feeb5
Update preprocessor.expect.txt
tomwt-awa 5f3966c
Update number-literals.expect.txt
tomwt-awa 7d18588
Update function-declarations.txt
tomwt-awa ad93c09
Update c.js
TOMWT-qwq 21b1994
Update cpp.js
TOMWT-qwq fb6b736
Update c.js
TOMWT-qwq de48b55
Update cpp.js
TOMWT-qwq 646dafa
Update function-declarations.expect.txt
TOMWT-qwq f61cf32
Update function-title.expect.txt
TOMWT-qwq 7b92fa5
Update c.js
TOMWT-qwq b7e2ed0
Update cpp.js
TOMWT-qwq dbcb2fc
Update c.js
TOMWT-qwq 372fa17
Update cpp.js
TOMWT-qwq 10f340c
Update c.js
TOMWT-qwq 92956cb
Update cpp.js
TOMWT-qwq f06c1e9
Update cpp.js
TOMWT-qwq 3b8812b
Update cpp.js
TOMWT-qwq ca4ad5b
Update cpp.js
TOMWT-qwq ef84dd7
Update cpp.js
TOMWT-qwq d9474fc
Update cpp.js
TOMWT-qwq d39e33d
Update cpp.js
TOMWT-qwq b1fec56
Merge pull request #4 from highlightjs/main
TOMWT-qwq aa00329
Update cpp.js
tomwt-awa 291a7e5
Update c.js
tomwt-awa 3f2ac85
Update function-declarations.expect.txt
tomwt-awa 2d4825e
Update function-title.expect.txt
tomwt-awa 674cbc6
Update function-declarations.expect.txt
tomwt-awa 82c65b5
Update function-title.expect.txt
tomwt-awa 85cf255
Update function-declarations.expect.txt
tomwt-awa 8bb807d
Update primitive-types.expect.txt
tomwt-awa dbae28a
Update template-complexity.expect.txt
tomwt-awa d9eb372
Update cpp.js
tomwt-awa 4e9d9c8
Update primitive-types.expect.txt
tomwt-awa f661965
Update template-complexity.expect.txt
tomwt-awa 31b522f
Update c.js
tomwt-awa 766973e
Update cpp.js
tomwt-awa f17b01a
Create operators.txt
tomwt-awa 53573e6
Create operator.expect.txt
tomwt-awa 8f43319
Delete test/markup/cpp/operator.expect.txt
tomwt-awa a46ae69
Create operators.expect.txt
tomwt-awa 7cc1ede
Update operators.expect.txt
tomwt-awa bc8ff34
Update cpp.js
TOMWT-qwq 717cfc5
Update function-title.expect.txt
TOMWT-qwq 670854c
Merge pull request #7 from TOMWT-qwq/test
TOMWT-qwq 0b5fca8
Update function-title.expect.txt
TOMWT-qwq d2f86a5
Update template-complexity.expect.txt
TOMWT-qwq bccbcf1
Merge branch 'main' into patch-1
TOMWT-qwq acca3b5
Update c.js
TOMWT-qwq e268836
Update cpp.js
TOMWT-qwq 2134bf4
Update cpp.js
TOMWT-qwq 5199d56
Update cpp.js
TOMWT-qwq a2e70d7
Update c.js
tomwt-awa 80f0ed1
Update cpp.js
tomwt-awa 529d225
Update c.js
tomwt-awa bbb0284
Update cpp.js
tomwt-awa b789408
Update cpp.js
tomwt-awa af6d69e
Update cpp.js
tomwt-awa f723bc5
Update cpp.js
tomwt-awa 2250e06
Update function-declarations.txt
TOMWT-qwq 8017a4d
Update function-declarations.expect.txt
TOMWT-qwq dbd21e5
Update operators.txt
TOMWT-qwq d85ec53
Update operators.expect.txt
TOMWT-qwq 97eeb05
Update cpp.js
TOMWT-qwq 1044882
Update CHANGES.md
TOMWT-qwq 2dccb73
Update cpp.js
TOMWT-qwq f951335
Update CHANGES.md
tomwt-awa b3b7cb1
Update cpp.js
tomwt-awa 6b8aae5
Update cpp.js
tomwt-awa c7034db
Update bugs.expect.txt
tomwt-awa ac95ee3
Update function-declarations.expect.txt
tomwt-awa 571a7c5
Update operators.expect.txt
tomwt-awa f1f131b
Update cpp.js
tomwt-awa c1629bd
Update template-complexity.txt
tomwt-awa 0b1e8fa
Update template-complexity.expect.txt
tomwt-awa acae136
Update function-declarations.expect.txt
tomwt-awa 985ab3f
Update cpp.js
tomwt-awa aa14119
Update cpp.js
tomwt-awa d427e0b
Update cpp.js
tomwt-awa 3cae087
Update cpp.js
tomwt-awa 8b6008a
Update cpp.js
tomwt-awa 19979fe
Update cpp.js
tomwt-awa 033a25b
Update cpp.js
tomwt-awa 6ab2a3a
Update cpp.js
tomwt-awa d75798a
Update function-declarations.expect.txt
tomwt-awa fb31034
Update operators.expect.txt
tomwt-awa 2c951fb
Update function-declarations.expect.txt
tomwt-awa 4275525
Update cpp.js
TOMWT-qwq 73fbcd2
Update function-declarations.expect.txt
TOMWT-qwq 947ab51
Update operators.expect.txt
TOMWT-qwq 89ab28e
Update CHANGES.md
TOMWT-qwq 69b2a41
Update c.js
tomwt-awa a089e2c
Update CHANGES.md
tomwt-awa 185dd8d
Update CHANGES.md
tomwt-awa 2e90a07
Update c.js
tomwt-awa 787692f
Update c.js
tomwt-awa 46a4f27
Update cpp.js
tomwt-awa 57e2eca
Update bugs.expect.txt
tomwt-awa e960809
Update function-declarations.expect.txt
tomwt-awa 582b823
Update operators.expect.txt
tomwt-awa 2cf37ee
Update operators.txt
tomwt-awa a07c668
Update operators.expect.txt
tomwt-awa a98b8f1
Update template-complexity.txt
TOMWT-qwq 8cb6942
Update template-complexity.expect.txt
TOMWT-qwq d8c6b61
Update template-complexity.txt
TOMWT-qwq 3269f61
Update template-complexity.expect.txt
TOMWT-qwq c7fd9fb
Update cpp.js
TOMWT-qwq 1b41b95
Update cpp.js
TOMWT-qwq 815d8fd
Merge branch 'main' into patch-1
TOMWT-qwq File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<span class="hljs-comment">//4. 对角矩阵</span> | ||
<span class="hljs-comment">//4.1 构造对角矩阵</span> | ||
<span class="hljs-function">Eigen::VectorXd <span class="hljs-title">vector</span><span class="hljs-params">(<span class="hljs-number">5</span>)</span></span>; <span class="hljs-comment">//构建5维向量</span> | ||
vector<<<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>; <span class="hljs-comment">//向量赋值</span> | ||
<span class="hljs-function">Eigen::MatrixXd <span class="hljs-title">C</span><span class="hljs-params">(vector.asDiagonal())</span></span>; <span class="hljs-comment">//使用向量生成对角阵</span> | ||
std::cout << <span class="hljs-string">"\nC= \n"</span> << C << std::endl; | ||
vector<span class="hljs-operator"><<</span><span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>; <span class="hljs-comment">//向量赋值</span> | ||
<span class="hljs-function">Eigen::MatrixXd <span class="hljs-title">C</span><span class="hljs-params">(vector<span class="hljs-operator">.</span>asDiagonal())</span></span>; <span class="hljs-comment">//使用向量生成对角阵</span> | ||
std::cout <span class="hljs-operator"><<</span> <span class="hljs-string">"\nC= \n"</span> <span class="hljs-operator"><<</span> C <span class="hljs-operator"><<</span> std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<span class="hljs-type">double</span> x = <span class="hljs-built_in">exp</span>(<span class="hljs-built_in">log</span>(<span class="hljs-number">2</span>)); <span class="hljs-comment">// recognize built-ins</span> | ||
<span class="hljs-type">double</span> x <span class="hljs-operator">=</span> <span class="hljs-built_in">exp</span>(<span class="hljs-built_in">log</span>(<span class="hljs-number">2</span>)); <span class="hljs-comment">// recognize built-ins</span> | ||
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>; <span class="hljs-comment">// recognize keyword that started the expression</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<span class="hljs-function"><span class="hljs-type">int</span> <span class="hljs-title">f</span><span class="hljs-params">( | ||
<span class="hljs-type">int</span> a = <span class="hljs-number">1</span>, | ||
<span class="hljs-type">char</span>* b = <span class="hljs-string">"2"</span>, <span class="hljs-comment">// Line comment</span> | ||
<span class="hljs-type">double</span> c = <span class="hljs-number">3.0</span>, <span class="hljs-comment">/* Block comment */</span> | ||
<span class="hljs-type">int</span> a <span class="hljs-operator">=</span> <span class="hljs-number">1</span>, | ||
<span class="hljs-type">char</span><span class="hljs-operator">*</span> b <span class="hljs-operator">=</span> <span class="hljs-string">"2"</span>, <span class="hljs-comment">// Line comment</span> | ||
<span class="hljs-type">double</span> c <span class="hljs-operator">=</span> <span class="hljs-number">3.0</span>, <span class="hljs-comment">/* Block comment */</span> | ||
ARRAY(<span class="hljs-type">int</span>, <span class="hljs-number">5</span>) d, | ||
<span class="hljs-type">void</span>* e __attribute__((unused)) | ||
<span class="hljs-type">void</span><span class="hljs-operator">*</span> e __attribute__((unused)) | ||
)</span></span>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<span class="hljs-function"><span class="hljs-type">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-type">int</span> argc, <span class="hljs-type">char</span>** argv)</span> </span>{ | ||
<span class="hljs-keyword">auto</span> a = std::<span class="hljs-built_in">make_unique</span><A>(); | ||
B *b = <span class="hljs-keyword">new</span> <span class="hljs-built_in">B</span>(); | ||
<span class="hljs-type">int</span> c = c * <span class="hljs-built_in">sum</span>(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>); | ||
<span class="hljs-keyword">if</span> (a-><span class="hljs-built_in">check1</span>()) | ||
<span class="hljs-function"><span class="hljs-type">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-type">int</span> argc, <span class="hljs-type">char</span><span class="hljs-operator">*</span><span class="hljs-operator">*</span> argv)</span> </span>{ | ||
<span class="hljs-keyword">auto</span> a <span class="hljs-operator">=</span> std<span class="hljs-operator">::</span><span class="hljs-built_in">make_unique</span><span class="hljs-operator"><</span>A<span class="hljs-operator">></span>(); | ||
B <span class="hljs-operator">*</span>b <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">B</span>(); | ||
<span class="hljs-type">int</span> c <span class="hljs-operator">=</span> c <span class="hljs-operator">*</span> <span class="hljs-built_in">sum</span>(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>); | ||
<span class="hljs-keyword">if</span> (a<span class="hljs-operator">-></span><span class="hljs-built_in">check1</span>()) | ||
<span class="hljs-keyword">return</span> <span class="hljs-number">3</span>; | ||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (a-><span class="hljs-built_in">check2</span>()) | ||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (a<span class="hljs-operator">-></span><span class="hljs-built_in">check2</span>()) | ||
<span class="hljs-keyword">return</span> <span class="hljs-number">4</span>; | ||
<span class="hljs-keyword">return</span> a-><span class="hljs-built_in">result</span>(); | ||
<span class="hljs-keyword">return</span> a<span class="hljs-operator">-></span><span class="hljs-built_in">result</span>(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string "operator" is not part of a function title... and if you are trying to highlight the operator itself as a
title.function
in these cases it'd be better to use a multi-matcher to do that... see the documentation forbeginMatch
... so we'd match:"operator" [ws] [operator]
and scope each segment differently.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean to highlight "operator" because I've noticed this case. I think it's a part of function title.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try the tools/developer.html tool? This already works without any additional
changes as I can tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operator
is detected as a keyword instead of title.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OH... I see what you're expecting now... hmmm... let me noodle on that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your opinion? You mean "operator" is used to decorate the real operator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think you are right after reading smth on cppreference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So how to deal with the overloaded operator?
title
oroperator
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But there is no
<span class="hljs-function"></span>
now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently nothing is working properly :(