Skip to content

Commit 6702bb5

Browse files
committed
Initial Commit
0 parents  commit 6702bb5

File tree

10 files changed

+835
-0
lines changed

10 files changed

+835
-0
lines changed

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# git
2+
.github/ export-ignore
3+
.gitattributes export-ignore
4+
.gitignore export-ignore
5+
6+
# screenshots
7+
preview.* export-ignore
8+
9+
# development
10+
tests/ export-ignore
11+
make.cmd export-ignore
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI Syntax Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '.github/workflows/ci-syntax-tests.yml'
9+
- '**.sublime-syntax'
10+
- '**/syntax_test_*'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/ci-syntax-tests.yml'
14+
- '**.sublime-syntax'
15+
- '**/syntax_test_*'
16+
workflow_dispatch:
17+
18+
jobs:
19+
syntax_tests:
20+
name: Sublime Text ${{ matrix.build }}
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 15 # default is 6 hours!
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
# Stable ST4 builds
28+
- build: 4152
29+
default_packages: binary
30+
htmx_ref: main
31+
jinja_ref: st4152
32+
- build: 4169
33+
default_packages: binary
34+
htmx_ref: main
35+
jinja_ref: st4152
36+
- build: 4180
37+
default_packages: binary
38+
htmx_ref: main
39+
jinja_ref: st4152
40+
- build: 4192
41+
default_packages: binary
42+
htmx_ref: main
43+
jinja_ref: st4152
44+
- build: 4200
45+
default_packages: binary
46+
htmx_ref: main
47+
jinja_ref: master
48+
# latest ST4 build and default syntaxes
49+
- build: latest
50+
default_packages: master
51+
htmx_ref: main
52+
jinja_ref: master
53+
steps:
54+
- name: Checkout Hyperflask
55+
uses: actions/checkout@v4
56+
with:
57+
path: Hyperflask
58+
- name: Checkout Hyperscript (dependency)
59+
uses: actions/checkout@v4
60+
with:
61+
repository: gnat/hyperscript-sublime
62+
ref: ${{ matrix.htmx_ref }}
63+
path: Hyperscript
64+
- name: Checkout Jinja2 (dependency)
65+
uses: actions/checkout@v4
66+
with:
67+
repository: Sublime-Instincts/BetterJinja
68+
ref: ${{ matrix.jinja_ref }}
69+
path: Jinja2
70+
- uses: SublimeText/syntax-test-action@v2
71+
with:
72+
build: ${{ matrix.build }}
73+
package_name: Hyperflask
74+
package_root: Hyperflask
75+
default_packages: ${{ matrix.default_packages }}
76+
additional_packages: Hyperscript,Jinja2

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# MacOS specific ignores
2+
.DS_Store
3+
4+
# development
5+
.sublime/
6+
.venv/
7+
.vscode/
8+
9+
# python cache files
10+
__pycache__/
11+
*.pyc

HTML (Hyperflask).sublime-syntax

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
%YAML 1.2
2+
---
3+
# https://github.com/hyperflask/jinjapy
4+
# https://github.com/hyperflask/jinja-super-macros
5+
# https://hyperflask.dev/guides/components/
6+
name: HTML (Hyperflask)
7+
scope: text.html.hyperflask
8+
version: 2
9+
10+
extends: Packages/Jinja2/Syntaxes/HTML/HTML (Jinja).sublime-syntax
11+
12+
file_extensions:
13+
- jpy
14+
15+
variables:
16+
# Jinja Super Macros
17+
super_macro_ident: (?:{{super_macro_ident_start}}{{super_macro_ident_part}}*)
18+
super_macro_ident_start: '[a-zA-Z_]'
19+
super_macro_ident_part: '[a-zA-Z0-9_-]*'
20+
21+
contexts:
22+
23+
###[ CUSTOM HTML ]############################################################
24+
25+
main:
26+
- meta_include_prototype: false
27+
- meta_scope: text.html.hyperflask meta.template.hyperflask
28+
- match: ''
29+
push: [html, frontmatter]
30+
31+
script-type-decider:
32+
- meta_prepend: true
33+
- match: (?=(?i:text/hyperscript{{unquoted_attribute_break}}|'text/hyperscript'|"text/hyperscript"))
34+
set:
35+
- script-hyperscript
36+
- tag-generic-attribute-meta
37+
- tag-generic-attribute-value
38+
39+
tag-other:
40+
- meta_prepend: true
41+
- include: jinja-super-macros
42+
43+
tag-attributes:
44+
- meta_prepend: true
45+
- include: tag-alpinejs-attributes
46+
- include: tag-hyperscript-attribute
47+
48+
merge-conflict-markers:
49+
# required until ST4199
50+
- meta_prepend: true
51+
52+
###[ JINJAPY FRONTMATTER ]####################################################
53+
54+
frontmatter:
55+
# https://github.com/hyperflask/jinjapy
56+
- meta_include_prototype: false
57+
# allow leading whitespace for proper highlighting in fenced code blocks
58+
- match: \s*(---)\s*\n
59+
captures:
60+
0: meta.frontmatter.jinjapy
61+
1: punctuation.section.frontmatter.begin.jinjapy
62+
2: constant.other.language-name.jinjapy
63+
embed: scope:source.python
64+
embed_scope: meta.frontmatter.jinjapy source.python.embedded.jinjapy
65+
escape: ^\s*(---)\s*$\n?
66+
escape_captures:
67+
0: meta.frontmatter.jinjapy
68+
1: punctuation.section.frontmatter.end.jinjapy
69+
pop: 1
70+
# Ensure to highlight frontmatter if the syntax is embedded, but pop as early as possible
71+
- match: ^|(?=\S)
72+
pop: 1
73+
74+
###[ JINJA SUPER MACROS ]######################################################
75+
76+
jinja-super-macros:
77+
# https://github.com/hyperflask/jinja-super-macros
78+
- match: (</?{)({{super_macro_ident}})
79+
captures:
80+
1: punctuation.definition.tag.begin.jinja
81+
2: entity.name.tag.component.super-macro.jinja
82+
push: jinja-super-macro-content
83+
84+
jinja-super-macro-content:
85+
- meta_include_prototype: false
86+
- meta_scope: meta.tag.component.super-macro.jinja
87+
- match: \}/?>
88+
scope: punctuation.definition.tag.end.jinja
89+
pop: 1
90+
- include: merge-conflict-markers
91+
- match: '{{super_macro_ident}}(?=\s*=)'
92+
scope: variable.parameter.jinja
93+
- include: Text (Jinja).sublime-syntax#expressions
94+
95+
###[ ALPINEJS ATTRIBUTES ]####################################################
96+
97+
tag-alpinejs-attributes:
98+
# :attr = shorthand syntax for x-bind:attribute="..."
99+
# @event = shorthand syntax for x-on:event="..."
100+
- match: '[:@]|(?=x-)'
101+
scope: entity.other.attribute-name.alpinejs.html punctuation.definition.attribute.alpinejs.html
102+
push:
103+
- tag-alpinejs-attribute-meta
104+
- tag-event-attribute-assignment
105+
- tag-alpinejs-attribute-name
106+
107+
tag-alpinejs-attribute-meta:
108+
- meta_include_prototype: false
109+
- meta_scope: meta.directive.other.alpinejs
110+
- include: immediately-pop
111+
112+
tag-alpinejs-attribute-name:
113+
- meta_content_scope: entity.other.attribute-name.alpinejs.html
114+
- include: tag-alpinejs-attribute-modifier
115+
- match: ':'
116+
scope: punctuation.definition.attribute.alpinejs.html
117+
- match: '["''`<]'
118+
scope: invalid.illegal.attribute-name.alpinejs.html
119+
120+
tag-alpinejs-attribute-modifier:
121+
- meta_content_scope: entity.other.attribute-name.alpinejs.html storage.modifier.alpinejs
122+
- match: '{{attribute_name_break}}'
123+
pop: 1
124+
- match: \.
125+
scope: entity.other.attribute-name.alpinejs.html punctuation.separator.key-value.alpinejs
126+
set: tag-alpinejs-attribute-modifier
127+
128+
###[ HYPERSCRIPT TAGS ]#######################################################
129+
130+
script-hyperscript:
131+
# Vendored from Hyperscript package
132+
- meta_scope: meta.tag.script.begin.html
133+
- match: '>'
134+
scope: punctuation.definition.tag.end.html
135+
set: script-hyperscript-content
136+
- include: script-common
137+
138+
script-hyperscript-content:
139+
- meta_include_prototype: false
140+
- match: \s*((<!\[)(CDATA)(\[))
141+
captures:
142+
1: meta.tag.sgml.cdata.html
143+
2: punctuation.definition.tag.begin.html
144+
3: keyword.declaration.cdata.html
145+
4: punctuation.definition.tag.begin.html
146+
pop: 1 # make sure to match only once
147+
embed: scope:source.hyperscript
148+
embed_scope: meta.tag.sgml.cdata.html source.hyperscript.embedded.html
149+
escape: \]\]>
150+
escape_captures:
151+
0: meta.tag.sgml.cdata.html punctuation.definition.tag.end.html
152+
- match: '{{script_content_begin}}'
153+
captures:
154+
1: comment.block.html punctuation.definition.comment.begin.html
155+
pop: 1 # make sure to match only once
156+
embed: scope:source.hyperscript
157+
embed_scope: source.hyperscript.embedded.html
158+
escape: '{{script_content_end}}'
159+
escape_captures:
160+
1: source.hyperscript.embedded.html
161+
2: comment.block.html punctuation.definition.comment.end.html
162+
3: source.hyperscript.embedded.html
163+
4: comment.block.html punctuation.definition.comment.end.html
164+
165+
###[ HYPERSCRIPT ATTRIBUTES ]#######################################################
166+
167+
tag-hyperscript-attribute:
168+
# Vendored from Hyperscript package
169+
- match: (?i:_|hs|data-hs){{attribute_name_break}}
170+
scope: entity.other.attribute-name.hyperscript.html
171+
push:
172+
- tag-hyperscript-attribute-meta
173+
- tag-hyperscript-attribute-assignment
174+
175+
tag-hyperscript-attribute-meta:
176+
- meta_include_prototype: false
177+
- meta_scope: meta.attribute-with-value.hyperscript.html
178+
- include: immediately-pop
179+
180+
tag-hyperscript-attribute-assignment:
181+
- match: =
182+
scope: punctuation.separator.key-value.html
183+
set:
184+
- immediately-pop
185+
- tag-hyperscript-attribute-value
186+
- include: else-pop
187+
188+
tag-hyperscript-attribute-value:
189+
- match: \"
190+
scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html
191+
embed: scope:source.hyperscript
192+
embed_scope: meta.string.html meta.interpolation.html source.hyperscript.embedded.html
193+
escape: \"
194+
escape_captures:
195+
0: meta.string.html string.quoted.double.html punctuation.definition.string.end.html
196+
pop: 1
197+
- match: \'
198+
scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html
199+
embed: scope:source.hyperscript
200+
embed_scope: meta.string.html meta.interpolation.html source.hyperscript.embedded.html
201+
escape: \'
202+
escape_captures:
203+
0: meta.string.html string.quoted.single.html punctuation.definition.string.end.html
204+
pop: 1
205+
- include: else-pop

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Sublime Text Packages
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Hyperflask
2+
3+
[Hyperflask Components][] syntax definition for [Sublime Text][] based on [Jinja2][] syntax.
4+
5+
![](preview.png)
6+
## Features:
7+
8+
Syntax Highlighting for
9+
10+
- AlpineJS
11+
- HTMX
12+
- [Jinjapy][] frontmatter
13+
- [Jinja Super Macros][] (e.g. `<{Component arg-name=[val for val in any.values] }/>`)
14+
- [Jinja2 Templates][]
15+
16+
## Installation
17+
18+
### Requirements
19+
20+
This package requires:
21+
22+
- Sublime Text 4152+
23+
- [Hyperscript][]
24+
- [Jinja2][]
25+
26+
### Package Control
27+
28+
The easiest way to install is using [Package Control][]. It's listed as `Hyperflask`.
29+
30+
1. Open `Command Palette` using <kbd>ctrl+shift+P</kbd> or menu item `Tools → Command Palette...`
31+
2. Choose `Package Control: Install Package`
32+
3. Find `Jinja2` and hit <kbd>Enter</kbd>
33+
4. Find `Hyperscript` and hit <kbd>Enter</kbd>
34+
5. Find `Hyperflask` and hit <kbd>Enter</kbd>
35+
36+
### Manual Install
37+
38+
1. Download [Hyperflask.sublime-package][].
39+
2. Download [Hyperscript][] package.
40+
3. Download [Jinja2.sublime-package][] package.
41+
4. Copy them into _Installed Packages_ directory
42+
43+
> [!NOTE]
44+
>
45+
> To find _Installed Packages_...
46+
>
47+
> 1. call _Menu > Preferences > Browse Packages.._
48+
> 2. Navigate to parent folder
49+
50+
> [!WARNING]
51+
>
52+
> Manually installed packages are not automatically updated by Package Control.
53+
54+
[Hyperflask Components]: https://hyperflask.dev/guides/components/
55+
[Hyperflask.sublime-package]: https://github.com/SublimeText/Hyperflask/releases/
56+
[Hyperscript]: https://packagecontrol.io/packages/Hyperscript
57+
[Jinja2]: https://packagecontrol.io/packages/Jinja2
58+
[Jinja2.sublime-package]: https://github.com/Sublime-Instincts/BetterJinja/releases/
59+
[Jinja2 Templates]: https://pypi.org/project/jinja2/
60+
[Jinjapy]: https://pypi.org/project/jinjapy/
61+
[Jinja Super Macros]: https://pypi.org/project/jinja-super-macros/
62+
[Package Control]: https://packagecontrol.io
63+
[Sublime Text]: https://www.sublimetext.com

0 commit comments

Comments
 (0)