Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/syntax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- build: latest
packages: master
- build: stable
packages: master
- build: 4134 # Need HTML with `html` context for inclusion
- build: 4149
packages: binary
steps:
- uses: actions/checkout@v4
Expand Down
19 changes: 4 additions & 15 deletions Razor/C# (Razor).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,8 @@ contexts:
- include: Packages/HTML (C#)/Razor/Razor.sublime-syntax#comments
- include: Packages/HTML (C#)/Razor/Razor.sublime-syntax#html

stray-braces:
- match: (\})(\s*\n)?
scope: meta.embedded.cs
captures:
1: punctuation.section.embedded.end.cs-razor
2: meta.html-newline-after-csharp.cs-razor # used by indentation rules
# - match: \}
# scope: invalid.illegal.stray.cs

stray-brackets:
- match: \]
scope: invalid.illegal.stray.cs

stray-parens:
- match: \)
stray_close_bracket:
- match: \]|\)
scope: invalid.illegal.stray.cs
- match: (?=})
pop: 1
10 changes: 1 addition & 9 deletions Razor/Razor.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,9 @@ contexts:
- meta_include_prototype: false
- match: '@@'
scope: constant.character.escape.cs-razor
- match: '\w+@\w+' # prevent email addresses being caught etc
- match: '{{csharp_tag_interpolation_bare}}'
- match: '\B{{csharp_tag_interpolation_bare}}'
scope: punctuation.section.interpolation.begin.razor
push: Packages/HTML (C#)/Razor/embeddings/C# (for C# Razor HTML attribute).sublime-syntax
#push: csharp-interpolation-body

csharp-interpolation-body:
# - clear_scopes: 1
- meta_include_prototype: false
- include: csharp-embedded
- include: immediately-pop

csharp-embedded:
- meta_include_prototype: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ contexts:
main:
- meta_prepend: true
- match: (?=")
pop: 1
pop: 3

line_of_code_in:
- meta_prepend: true
- match: (?=")
pop: 1
pop: 3
35 changes: 33 additions & 2 deletions Razor/tests/syntax_test_cshtml.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,36 @@ else
} *@
<!-- ^^ comment.block punctuation.definition.comment -->

@{ }
<!--^^^^^^ meta.embedded.cs -->
<!--^^ punctuation.section.embedded.begin.cs-razor - source -->
<!-- ^ source.cs.embedded.html -->
<!-- ^ punctuation.section.embedded.end.cs-razor - source -->
<!-- ^^ meta.html-newline-after-csharp.cs-razor - source -->

@{
var quote = "The future depends on what you do today. - Mahatma Gandhi";
<!-- ^^ source.cs.embedded -->
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.embedded.cs source.cs.embedded.html -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ keyword.operator.assignment.variable.cs -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.cs string.quoted.double.cs -->
<!-- ^ punctuation.definition.string.begin.cs -->
<!-- ^ punctuation.definition.string.end.cs -->
<!-- ^ punctuation.terminator.statement.cs -->
}
<!-- ^ text.html - source -->

<p>@quote</p>
<p>@quote</p>
<!--^^^ meta.tag.block.any.html -->
<!--^ punctuation.definition.tag.begin.html -->
<!-- ^ entity.name.tag.block.any.html -->
<!-- ^ punctuation.definition.tag.end.html -->
<!-- ^ punctuation.section.embedded.line.cs-razor -->
<!-- ^^^^^ source.cs.embedded.html variable.other.cs -->
<!-- ^^^^ meta.tag.block.any.html -->
<!-- ^^ punctuation.definition.tag.begin.html -->
<!-- ^ entity.name.tag.block.any.html -->
<!-- ^ punctuation.definition.tag.end.html -->

@{
quote = "Hate cannot drive out hate, only love can do that. - Martin Luther King, Jr.";
Expand Down Expand Up @@ -304,9 +327,17 @@ finally

@{
/* C# comment */
<!--^^^^^^^^^^^^^^^^ meta.embedded.cs source.cs.embedded.html -->
<!--^^^^^^^^^^^^^^^^ comment.block.cs -->
<!--^^ punctuation.definition.comment.begin.cs -->
<!-- ^^ punctuation.definition.comment.end.cs -->
// Another C# comment
<!--^^^^^^^^^^^^^^^^^^^^^ meta.embedded.cs source.cs.embedded.html -->
<!--^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.cs -->
<!--^^ punctuation.definition.comment.cs -->
}
<!-- HTML comment -->
<!-- ^^^^^^^^^^^^^^^^ comment.block.html -->


@functions {
Expand Down
17 changes: 5 additions & 12 deletions WebForms/C# (WebForms).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ extends: Packages/C#/C#.sublime-syntax
##############################################################################

contexts:
statements:
- meta_prepend: true
- match: (?=%>)
pop: 1

code_block_in:
- meta_prepend: true
- match: (%>)(\s*\n)?
Expand All @@ -27,15 +32,3 @@ contexts:
pop: 1
- include: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax#comments
- include: Packages/HTML (C#)/WebForms/WebForms.sublime-syntax#html

stray-braces:
- match: \}
scope: invalid.illegal.stray.cs

stray-brackets:
- match: \]
scope: invalid.illegal.stray.cs

stray-parens:
- match: \)
scope: invalid.illegal.stray.cs
39 changes: 31 additions & 8 deletions WebForms/tests/syntax_test_aspx.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,45 @@
<body>
<my:Bar runat="server" />

<% %>
<%--^^^^^ meta.embedded.cs --%>
<%--^^ punctuation.section.embedded.begin.cs-webforms --%>
<%-- ^ source.cs.embedded.html --%>
<%-- ^^ punctuation.section.embedded.end.cs-webforms - source --%>

<% } %>
<%--^^^^^^^ meta.embedded.cs --%>
<%--^^ punctuation.section.embedded.begin.cs-webforms --%>
<%-- ^^^ source.cs.embedded.html --%>
<%-- ^ invalid.illegal.stray.brace.cs --%>
<%-- ^^ punctuation.section.embedded.end.cs-webforms - source --%>

<% if(3 > 10)
<%--^^ punctuation.section.embedded.begin - source.cs --%>
<%-- ^^^^^^^^^^ source.cs.embedded.html --%>
{ %>
<%-- ^ punctuation.section.block.begin --%>
<%-- ^^ punctuation.section.embedded.end --%>
<%-- ^^^^^ - source.cs.embedded.html --%>
<%--^^^^^^ meta.embedded.cs source.cs.embedded.html --%>
<%-- ^ punctuation.section.block.begin.cs --%>
<%-- ^^ text.html.cs.webforms meta.embedded.cs punctuation.section.embedded.end.cs-webforms - source --%>
<p>Baz</p>
<% } else { %>
<%-- ^^^^^^^^^^ source.cs.embedded.html --%>
<%-- ^ punctuation.section.block.end --%>
<%-- ^^^^ keyword.control.conditional.else --%>
<%-- ^ punctuation.section.block.begin --%>
<%-- ^^^ - source.cs.embedded.html --%>
<%--^^ text.html.cs.webforms --%>
<%--^^ meta.embedded.cs punctuation.section.embedded.begin.cs-webforms --%>
<%-- ^^^^^^^^^^ meta.embedded.cs source.cs.embedded.html --%>
<%-- ^ punctuation.section.block.end.cs --%>
<%-- ^^^^^ keyword.control.conditional.else.cs --%>
<%-- ^^ meta.block.cs --%>
<%-- ^ punctuation.section.block.begin.cs --%>
<%-- ^^ text.html.cs.webforms meta.embedded.cs punctuation.section.embedded.end.cs-webforms - source --%>
<p>Biff</p>
<% } %>
<%--^^ text.html.cs.webforms --%>
<%--^^ meta.embedded.cs punctuation.section.embedded.begin.cs-webforms --%>
<%-- ^^^^^ meta.embedded.cs --%>
<%-- ^^^ source.cs.embedded.html --%>
<%-- ^^ meta.block.cs --%>
<%-- ^ punctuation.section.block.end.cs --%>
<%-- ^^ punctuation.section.embedded.end.cs-webforms - source --%>

<p><%: variable %></p>
<%-- ^^^ punctuation.section.embedded.begin --%>
Expand Down
Loading