Skip to content

Commit

Permalink
Add Jinja2 language to Code component (#9545)
Browse files Browse the repository at this point in the history
* Add jinja2 codemirror language

* add jinja2

* add changeset

---------

Co-authored-by: gradio-pr-bot <[email protected]>
  • Loading branch information
CISC and gradio-pr-bot authored Oct 5, 2024
1 parent d826faa commit 098a009
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/mighty-goats-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/code": minor
"gradio": minor
---

feat:Add Jinja2 language to Code component
2 changes: 2 additions & 0 deletions gradio/components/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Code(Component):
"html",
"css",
"javascript",
"jinja2",
"typescript",
"yaml",
"dockerfile",
Expand Down Expand Up @@ -69,6 +70,7 @@ def __init__(
"html",
"css",
"javascript",
"jinja2",
"typescript",
"yaml",
"dockerfile",
Expand Down
5 changes: 5 additions & 0 deletions js/code/shared/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const possible_langs = [
"html",
"css",
"javascript",
"jinja2",
"typescript",
"yaml",
"dockerfile",
Expand Down Expand Up @@ -58,6 +59,10 @@ const lang_map: Record<string, (() => Promise<Extension>) | undefined> = {
css: () => import("@codemirror/lang-css").then((m) => m.css()),
javascript: () =>
import("@codemirror/lang-javascript").then((m) => m.javascript()),
jinja2: () =>
import("@codemirror/legacy-modes/mode/jinja2").then((m) =>
StreamLanguage.define(m.jinja2)
),
typescript: () =>
import("@codemirror/lang-javascript").then((m) =>
m.javascript({ typescript: true })
Expand Down

0 comments on commit 098a009

Please sign in to comment.