Select to view content in your preferred language

What language is Arcade most like for syntax highlighting?

1762
5
Jump to solution
10-27-2020 06:04 PM
AndrewQuee
Frequent Contributor

We store business information using mediawiki and share template code snippets from all our development environments using the syntaxhighlight extension which uses Pygments to do automatic syntax formatting in the page. 

Arcade is not in the 'hundreds of languages' Pygments supports (and I acknowledge this is not the venue to ask for Pygments or Mediawiki support) but I just wanted to ask what root language is Arcade most like?  It doesn't need to be 100% accurate but anyone who's read code with <pre> tags knows it doesn't 'spark joy'.

Over at Using Arcade expressions in web apps  they said 

Arcade is similar to other scripting and expression languages, such as SQL, Python, VBScript and spreadsheet formulas. ...It has syntax similar to JavaScript...

The closest and nicest-looking syntax I've seen is java but I was wondering out of those hundreds what the closest match is.  Javascript is mentioned a lot over at Arcade | ArcGIS API for JavaScript 4.17  but when I apply that under syntaxhighlighter it actually looks quite 'meh', although that could just be my style markup.

Edit: This is what I mean by 'meh' styling if you're interested.  No fault of Arcade, Mediawiki or Pygments, it is what it is.

Comparison of default MW markup and Esri markup for Arcade

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Andrew Quee ,

To add to what Dan Patterson is suggesting, in GeoNet I always use JavaScript as syntax highlighting. 

In Mediawiki in the past (a long time ago) when I was coding with ArcObjects we creating our own highlighting language including all the objects from ArcObjects. I don't know Pygments but maybe it has a an option to define a customized language and use JavaScript as basis and include the Arcade functions. 

View solution in original post

5 Replies
DanPatterson
MVP Esteemed Contributor

syntax highlighting and code linting are 'meh' or absent.

https://community.esri.com/ideas/18665 

has a particular request in general, and specific to an IDE.  Perhaps you can jump on that idea or use the javascript (as suggested there as well) in the interim


... sort of retired...
XanderBakker
Esri Esteemed Contributor

Hi Andrew Quee ,

To add to what Dan Patterson is suggesting, in GeoNet I always use JavaScript as syntax highlighting. 

In Mediawiki in the past (a long time ago) when I was coding with ArcObjects we creating our own highlighting language including all the objects from ArcObjects. I don't know Pygments but maybe it has a an option to define a customized language and use JavaScript as basis and include the Arcade functions. 

AndrewQuee
Frequent Contributor

Thanks very much Xander and Dan Patterson‌, I knew it was an easy question, I just couldn't find the answer in the FAQ etc.   I really think that the issue is in my markup, so while I might not be up to writing a lexer, I definitely think I can do something on the javascript configuration.

If someone on the Esri side would like to expand on what they use for the nice markup shown in code snippets on Esri websites that'd be lovely, otherwise I might do some reverse-engineering through mediawiki.

0 Kudos
DanPatterson
MVP Esteemed Contributor

For those that are bored

Write your own lexer — Pygments 


... sort of retired...
AndrewQuee
Frequent Contributor

Thanks.  I'll just add that I discovered that Pygments has about half a dozen sub-lexers for Javascript variants.  When I tested these in Mediawiki/Syntaxhighlight to see if they were compatible with Arcade (albeit for completely the wrong language) one or two aspired to the mediocracy of the javascript lexer, the rest were dire/inapplicable.

This isn't a deal breaker for me/us, so will go onto the backburner (read: locked filing cabinet in disused toilet at bottom of unlit stairwell) until I get spare time to look at it.  I had a brief look at making a lexer, seems quite overkill for the benefit of making text look nice.  I might look at simply altering the existing colour values for the javascript lexer as a quick fix.

0 Kudos