Git Product home page Git Product logo

Comments (8)

canibanoglu avatar canibanoglu commented on July 20, 2024 1

Alright, that makes a lot of sense :) I'll try to get something up this weekend

from shiki.

canibanoglu avatar canibanoglu commented on July 20, 2024

I'm looking into this but I have a question. I found this repo which includes a lot of syntaxes for various combinations of Jinja with other languages.

This works just fine in VS Code due to file extensions but with shiki there's a need for explicitly specifiying which language to use for tokenization. Which means that to have JS syntax highlighting within a Jinja template you'd have to pass jinja-js which wouldn't necessarily work with CSS highlighting within the same file.

The question is what is the desired API? Do we want to have things work automagically when we just pass jinja as the language or is it OK if we expect the user to specify which one they want to use specifically (like jinja-js or jinja-css)? I can't think of an easy way to implement the first one and the second one is a bit limited because you'd have to add a new syntax file for every combination you would want to use.

Or we just add Jinja's raw syntax and leave it at that. Thoughts?

from shiki.

Uninen avatar Uninen commented on July 20, 2024

At least for me during past ~15 years of Django development, most code involving Djano/Jinja templates have mostly or fully been HTML-only (not including special cases when you're intentionally writing something special w/ other languages but usually no code formatter works in those cases).

I'm not sure what's the difference between first case and just implementing the raw Jinja syntax? I think the initial solution could (and should) be as simple as possible, and if someone needs a more fine-tuned API, they can file a new ticket for the specific use case which then can be evaluated case by case. In other words, the basic use case would be jinja-html or whatever the base Jinja syntax is :)

from shiki.

octref avatar octref commented on July 20, 2024

I'm not sure if something is missing, but this doesn't look right and I'm not familiari with Jinja.

image

I'm using:
https://github.com/samuelcolvin/jinjahtml-vscode/blob/master/syntaxes/jinja.tmLanguage.json

from shiki.

Uninen avatar Uninen commented on July 20, 2024

Indeed, no, it does not look right. Jinja is a superset of Django templates, most Django (vscode) plugins seem to get the syntax right.

Although, as with all templates and colorizations, it's also somewhat of opinion as well...

from shiki.

octref avatar octref commented on July 20, 2024

It seems django can generate any text file and has no strict grammar. How should it be highlighted then?

from shiki.

Uninen avatar Uninen commented on July 20, 2024

Well that is true in the sense that Django is just a tool like Vue, but Django templates do have a strictly defined grammar just as Vue templates do. (You can opt-out from using the template language but obviously then you're not expecting to use template highlighter tools either.)

I'm not really sure how Django templates are defined, though. I'm sorry if my previous comment was misleading. I meant that the styling (theme) of the syntax highlighting is a matter of opinion, not the syntax itself. (In the posted example above the HTML is not properly highlighted for example, but most Django template tools do highlight HTML as it should be in my opinion.)

If it helps I can dig up the source for Django templates or maybe some examples of vscode plugins? I'm not an expert of these matters by any means but I'm happy to help in any way I can.

from shiki.

octref avatar octref commented on July 20, 2024

OK, I added jinja-html lang:

image

from shiki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.