Comments (8)
Alright, that makes a lot of sense :) I'll try to get something up this weekend
from shiki.
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.
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.
I'm not sure if something is missing, but this doesn't look right and I'm not familiari with Jinja.
I'm using:
https://github.com/samuelcolvin/jinjahtml-vscode/blob/master/syntaxes/jinja.tmLanguage.json
from shiki.
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.
It seems django can generate any text file and has no strict grammar. How should it be highlighted then?
from shiki.
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.
OK, I added jinja-html
lang:
from shiki.
Related Issues (20)
- `@shikijs/vitepress-twoslash`: Use twoslash in the case of using imported code snippets.
- Row of `language-*` on a single `code` element HOT 1
- Vue 当没有写 `template` 时无法正常高亮 HOT 1
- @shikijs/markdown-it: code block is wrong when entering a non-existent language HOT 2
- Twoslash node query blocks (^?) no longer display on separate lines since 0.x
- `remove-notation-escape`: notation escape syntax’s normalize transformer HOT 2
- Rehype: default language
- "TypeError: onigBinding.UTF8ToString is not a function" after some time / parallel requests in Next.js HOT 10
- Inconsistent behavior between `@shikijs/twoslash` and `@shikijs/vitepress-twoslash`
- Diff syntax highlighting doesn't work with css variables theme
- `light-dark()` CSS function for dual themes HOT 3
- how to use codeToHtml + transformer (meta) ? HOT 5
- Detect Notation Transformers dynamically
- Properly disposing of highlighters HOT 1
- Describe the bug here HOT 2
- `@shikijs/rehype`: support `langAlias` options
- Optimization suggestions for the 'hast' type in Shiki.js HOT 2
- `@shikijs/rehype` - "30 instances have been created" HOT 6
- Return the grammar state after tokenizing HOT 2
- shiki/wasm dependency not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shiki.