PrismJS / prism

Lightweight, robust, elegant syntax highlighting.
https://prismjs.com
MIT License
12.33k stars 1.3k forks source link

Add support for Apex #2604

Closed lukethacoder closed 3 years ago

lukethacoder commented 4 years ago

Language Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on Salesforce servers in conjunction with calls to the API. Using syntax that looks like Java and acts like database stored procedures, Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages.

Check out the official docs

Is it worth adding what would essentially be an alias of the java language as an entirely new language definition. Noticed you can alias a language (but still displays as the actual language you're aliasing when using the 'display language' addon), but can you go the other way.

image

Could run this, but seems overkill to add an entire new language definition if its practically the same as the java definition.

// prism-apex.js
;(function (Prism) {
  Prism.languages.apex = Prism.languages.java
})(Prism)
RunDevelopment commented 4 years ago

Prism's Java language definition is specifically made for Java code. Some of the highlighting is even dependent on Java's naming conventions which aren't enforced in Apex. While an alias may work as a temporary workaround, it's not enough for Prism.

seems overkill to add an entirely new language definition if it's practically the same as the java definition.

I took a look at the doc and the languages seem very different to me. One of the more obvious differences is SOQL and SOSL queries but there are many more besides that.