Author Topic: YAML and jinja  (Read 275 times)

garion911

  • Senior Community Member
  • Posts: 186
  • Hero Points: 13
YAML and jinja
« on: May 25, 2018, 07:54:49 pm »
Hi all.. I've been working with YAML and jinja for a bit now. I've come up with a basic YAML and jinja config that at least does *some* syntax highlighting.

YAML is the base language, and allows jinja to be embedded. (a common env for Salt at least).

The biggest hurdle I had, was getting to recognize jinja as an embed language properly. I ended up doing some regex with lookahead.. So in the YAML file, the search for jinja looks like {(?=[#%{]) and (?=[#%}])}. Then in the jinja area, I only really look for (begin) # and  (end) # for comments.. Then I have some other definitions to highlight if, endif, else, etc.. its not complete, but I believe its a reasonable start.

I think we need better support for templating languages in SE. Have a section where we could define templating languages (like application or scripting languages), and then in each language, have a section for 'allowed templating languages' or something. It would also be nice to not have to do the lookahead on the regex's to determine if we're in one.

Anyways, I attached my exported jinja and yaml settings for everyone.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4485
  • Hero Points: 344
Re: YAML and jinja
« Reply #1 on: May 25, 2018, 08:46:01 pm »
It’s tricky to make the color coding engine powerful AND easy to use. The latest engine is a lot better but some languages can’t be done by the user. Examples: CSS. Markdown, HTML, XML, JCL

YAML reminds me of markdown where indent matters and creates new states. The docs I’ve seen on YAML are pretty bad. We will have reverse engineer it when we add support for it.

I don’t know if we will ever add some sort of advanced parse tree stuff to the color coding engine.

garion911

  • Senior Community Member
  • Posts: 186
  • Hero Points: 13
Re: YAML and jinja
« Reply #2 on: May 29, 2018, 07:43:30 pm »
Not sure if you know already or not, but there is an official spec for YAML. http://yaml.org/spec/1.2/spec.html

I can understand the problem with templating languages that wrap other languages. I've had fun with a template language that wrapped another template language that finally had a real language. (A wacky code generator tool I wrote). Then you have embedded documentation in yet another format, and yeah. I sense your pain.