feat: improved syntax highlighting for the solidity
language
#435
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.
🧰 Changes
When I added support for the Solidity language1 in #219 I pretty half-assed it by treating all code in that language as C-like, which is sort of true as it does has elements of C. In reality, this ends up treating most every keyword and aspect of the language as a C language
comment
or avariable
, resulting in everything being highlighted as green:There's a codemirror-solidity library that handles this as it should2 but unfortunately it can't be imported in here because of the way that it defines its Codemirror mode3. Because of this, I've pulled that source over into this library, added attribution where necessary, and updated our Solidity example to better reflect real-world usage of the language4.
tl;dr: Our Solidity highlighting sucks, is better now.
Footnotes
Solidity is for blockchain programming. ↩
https://alincode.github.io/codemirror-solidity/ ↩
https://github.com/alincode/codemirror-solidity/blob/master/index.js ↩
https://docs.soliditylang.org/en/latest/solidity-by-example.html ↩