Skip to content

Commit

Permalink
Merge pull request #1855 from riganti/fix/compilation-page-warnings
Browse files Browse the repository at this point in the history
Fixed warnings in compilation status page
  • Loading branch information
exyi authored Sep 8, 2024
2 parents 2977480 + 2f57498 commit b6cc7e8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,14 @@ private ReadElementType ReadElement(bool wasOpenBraceRead = false)

if (!char.IsLetterOrDigit(firstChar) & firstChar != '/' & firstChar != ':')
{
CreateToken(DothtmlTokenType.Text, errorProvider: t => CreateTokenError(t, "'<' char is not allowed in normal text"));
if (char.IsWhiteSpace(firstChar))
{
CreateToken(DothtmlTokenType.Text);
}
else
{
CreateToken(DothtmlTokenType.Text, errorProvider: t => CreateTokenError(t, "'<' char is not allowed in normal text"));
}
return ReadElementType.Error;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class={value: $"compilation-diagnostic compilation-{Severity.ToString().ToLowerInvariant()}"}>
<div class="source code">
<div Class={value: $"source-{Severity.ToString().ToLowerInvariant()}Line"}>
<div class={value: $"source-{Severity.ToString().ToLowerInvariant()}Line"}>
<pre><span class="lineNumber" IncludeInPage={value: LineNumber != null}>{{value: LineNumber}}: </span><span class="codeLine">{{value: SourceLinePrefix}}<span class={value: $"{Severity.ToString().ToLowerInvariant()}Underline"}>{{value: SourceLineHighlight}}</span>{{value: SourceLineSuffix}}</span></pre>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<dot:Placeholder IncludeInPage={value: _control.Diagnostics.Length > 0}>
<dot:Repeater DataSource={value: _control.Diagnostics.Take(_control.DisplayLimit)} RenderWrapperTag=false >
<tr Class="row-continues">
<tr class="row-continues">
<td colspan="5">
<dotvvm-internal:CompilationDiagnostic style="margin-left: 3rem" />
</td>
Expand Down
12 changes: 12 additions & 0 deletions src/Tests/Parser/Dothtml/DothtmlTokenizerElementsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ public void DothtmlTokenizer_Invalid_OpenBraceInText()
tokenizer.Tokenize(input);

Assert.IsTrue(tokenizer.Tokens.All(t => t.Type == DothtmlTokenType.Text));
Assert.IsTrue(tokenizer.Tokens.All(t => !t.HasError));
Assert.AreEqual(string.Concat(tokenizer.Tokens.Select(t => t.Text)), input);
}

[TestMethod]
public void DothtmlTokenizer_Invalid_OpenBraceInTextWithoutSpace()
{
var input = "inline <script";
var tokenizer = new DothtmlTokenizer();
tokenizer.Tokenize(input);

Assert.IsTrue(tokenizer.Tokens.Any(t => t.HasError));
Assert.AreEqual(string.Concat(tokenizer.Tokens.Select(t => t.Text)), input);
}

Expand Down

0 comments on commit b6cc7e8

Please sign in to comment.