Skip to content

wip support C# code inside HTML attributes without lookbehinds #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
11 changes: 9 additions & 2 deletions Razor/Razor.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ contexts:
- meta_prepend: true
- include: csharp-interpolations

tag-generic-attribute-value-content:
- meta_prepend: true
- include: csharp-interpolations

strings-common-content:
- meta_prepend: true
- include: csharp-interpolations
Expand Down Expand Up @@ -303,8 +307,11 @@ contexts:
- meta_include_prototype: false
- match: '@@'
scope: constant.character.escape.cs-razor
- match: (?={{csharp_tag_interpolation_bare}})
push: csharp-interpolation-body
- match: '\w+@\w+' # prevent email addresses being caught etc
- match: '{{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
Expand Down
18 changes: 18 additions & 0 deletions Razor/embeddings/C# (for C# Razor HTML attribute).sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%YAML 1.2
---
scope: source.cs.embedded.html-attribute-string.razor
version: 1
hidden: true

extends: Packages/C#/C#.sublime-syntax

contexts:
main:
- meta_prepend: true
- match: (?=")
pop: 1

line_of_code_in:
- meta_prepend: true
- match: (?=")
pop: 1
139 changes: 139 additions & 0 deletions Razor/tests/syntax_test_cshtml.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,145 @@

<p>@quote</p>

<div class="grid-mvc" data-lang="@Model.Language" data-gridname="@Model.RenderOptions.GridName" data-selectable="@Model.RenderOptions.Selectable.ToString().ToLower()" data-multiplefilters ="@Model.RenderOptions.AllowMultipleFilters.ToString().ToLower()">
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.block.any.html -->
<!-- ^^^^^^^^^^^^^^^^ meta.attribute-with-value.class.html -->
<!-- ^^^^^ entity.other.attribute-name.class.html -->
<!-- ^ punctuation.separator.key-value.html -->
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html -->
<!-- ^^^^^^^^ meta.class-name.html meta.string.html string.quoted.double.html -->
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html -->
<!-- ^^^^^^^^^ entity.other.attribute-name.html -->
<!-- ^ punctuation.separator.key-value.html -->
<!-- ^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
<!-- ^ punctuation.definition.string.begin.html -->
<!-- ^ punctuation.section.interpolation.begin.razor -->
<!-- ^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^ variable.other.cs -->
<!-- ^ punctuation.definition.string.end.html -->
<!-- ^^^^^^^^^^^^^ entity.other.attribute-name.html -->
<!-- ^ punctuation.separator.key-value.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
<!-- ^ punctuation.definition.string.begin.html -->
<!-- ^ punctuation.section.interpolation.begin.razor -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^ variable.other.cs -->
<!-- ^ punctuation.definition.string.end.html -->
<!-- ^^^^^^^^^^^^^^^ entity.other.attribute-name.html -->
<!-- ^ punctuation.separator.key-value.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
<!-- ^ punctuation.definition.string.begin.html -->
<!-- ^ punctuation.section.interpolation.begin.razor -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^ meta.function-call.cs -->
<!-- ^^^^^^^^ variable.function.cs -->
<!-- ^^ meta.group.cs -->
<!-- ^ punctuation.section.group.begin.cs -->
<!-- ^ punctuation.section.group.end.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^ meta.function-call.cs -->
<!-- ^^^^^^^ variable.function.cs -->
<!-- ^^ meta.group.cs -->
<!-- ^ punctuation.section.group.begin.cs -->
<!-- ^ punctuation.section.group.end.cs -->
<!-- ^ punctuation.definition.string.end.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^ entity.other.attribute-name.html -->
<!-- ^ punctuation.separator.key-value.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
<!-- ^ punctuation.definition.string.begin.html -->
<!-- ^ punctuation.section.interpolation.begin.razor -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^^^^^^^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^ meta.function-call.cs -->
<!-- ^^^^^^^^ variable.function.cs -->
<!-- ^^ meta.group.cs -->
<!-- ^ punctuation.section.group.begin.cs -->
<!-- ^ punctuation.section.group.end.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^ meta.function-call.cs -->
<!-- ^^^^^^^ variable.function.cs -->
<!-- ^^ meta.group.cs -->
<!-- ^ punctuation.section.group.begin.cs -->
<!-- ^ punctuation.section.group.end.cs -->
<!-- ^ punctuation.definition.string.end.html -->
<!-- ^ punctuation.definition.tag.end.html -->

<li>
<a href="@Model.GetLinkForPage(Model.CurrentPage - 1)">«</a>

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html punctuation.definition.tag.begin.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html entity.name.tag.inline.a.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html meta.attribute-with-value.href.html entity.other.attribute-name.href.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html meta.attribute-with-value.href.html entity.other.attribute-name.href.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html meta.attribute-with-value.href.html entity.other.attribute-name.href.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html meta.attribute-with-value.href.html entity.other.attribute-name.href.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html meta.attribute-with-value.href.html punctuation.separator.key-value.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html meta.attribute-with-value.href.html meta.string.html string.quoted.double.html punctuation.definition.string.begin.html]

Check failure on line 218 in Razor/tests/syntax_test_cshtml.cshtml

View workflow job for this annotation

GitHub Actions / Syntax Tests (4134)

[meta.tag.inline.any.html] does not match scope [text.html.cs.razor meta.tag.inline.a.html meta.attribute-with-value.href.html meta.path.url.html meta.string.html string.quoted.double.html punctuation.section.interpolation.begin.razor]
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.inline.any.html -->
<!--^ punctuation.definition.tag.begin.html -->
<!-- ^ entity.name.tag.inline.any.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.href.html -->
<!-- ^^^^ entity.other.attribute-name.href.html -->
<!-- ^ punctuation.separator.key-value.html -->
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.url.html meta.string.html string.quoted.double.html -->
<!-- ^ punctuation.section.interpolation.begin.razor -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.cs -->
<!-- ^^^^^^^^^^^^^^ variable.function.cs -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.group.cs -->
<!-- ^ punctuation.section.group.begin.cs -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^^ variable.other.cs -->
<!-- ^ keyword.operator.cs -->
<!-- ^ meta.number.integer.decimal.cs constant.numeric.value.cs -->
<!-- ^ punctuation.section.group.end.cs -->
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html -->
<!-- ^ punctuation.definition.tag.end.html -->
<!-- ^^ punctuation.definition.tag.begin.html -->
<!-- ^ entity.name.tag.inline.any.html -->
<!-- ^ punctuation.definition.tag.end.html -->
</li>
<li>
<a href="@Model.FunctionCall("embedded string")">"quotes" everywhere</a>
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.inline.any.html -->
<!--^ punctuation.definition.tag.begin.html -->
<!-- ^ entity.name.tag.inline.any.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.href.html -->
<!-- ^^^^ entity.other.attribute-name.href.html -->
<!-- ^ punctuation.separator.key-value.html -->
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.url.html meta.string.html string.quoted.double.html -->
<!-- ^ punctuation.section.interpolation.begin.razor -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
<!-- ^^^^^ variable.other.cs -->
<!-- ^ punctuation.accessor.dot.cs -->
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.cs -->
<!-- ^^^^^^^^^^^^ variable.function.cs -->
<!-- ^^^^^^^^^^^^^^^^^^^ meta.group.cs -->
<!-- ^ punctuation.section.group.begin.cs -->
<!-- ^^^^^^^^^^^^^^^^^ meta.string.cs string.quoted.double.cs -->
<!-- ^ punctuation.definition.string.begin.cs -->
<!-- ^ punctuation.definition.string.end.cs -->
<!-- ^ punctuation.section.group.end.cs -->
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html -->
<!-- ^ punctuation.definition.tag.end.html -->
<!-- ^^ punctuation.definition.tag.begin.html -->
<!-- ^ entity.name.tag.inline.any.html -->
<!-- ^ punctuation.definition.tag.end.html -->
</li>

@using (Html.BeginForm())
{
<div>
Expand Down