Fix highlighting name
Some checks are pending
MSBuild / build (push) Waiting to run
MSBuild / publish (push) Blocked by required conditions

This commit is contained in:
ema
2025-05-26 05:42:27 +08:00
parent b81b2f9ef8
commit 6deadf9d73
5 changed files with 126 additions and 13 deletions

View File

@@ -181,7 +181,7 @@ public class Plugin : IViewer
Debug.WriteLine(resourceName);
var hlm = resourceName.Contains(".Syntax.Dark.") ? _hlmDark : _hlmLight;
var ext = Path.GetFileNameWithoutExtension(resourceName);
var ext = Path.GetFileNameWithoutExtension(resourceName.ToResourceDummyName());
using var reader = new XmlTextReader(s);
var xshd = HighlightingLoader.LoadXshd(reader);
var highlightingDefinition = HighlightingLoader.Load(xshd, hlm);
@@ -216,3 +216,35 @@ public class Plugin : IViewer
}
}
}
file static class ResourceNameHelper
{
/// <summary>
/// Converts a resource name (using '.' as separators) into a dummy file path
/// by replacing inner dots with backslashes, while preserving the file extension.
///
/// Example:
/// Input: "Resources.Images.icon.png"
/// Output: "Resources\Images\icon.png"
///
/// Input: "Assets.Sounds.music.background.mp3"
/// Output: "Assets\Sounds\music\background.mp3"
/// </summary>
/// <param name="resourceName">The embedded resource name (excluding the default namespace).</param>
/// <returns>A string representing the resource as a dummy file path.</returns>
public static string ToResourceDummyName(this string resourceName)
{
if (string.IsNullOrWhiteSpace(resourceName))
return resourceName;
int lastDotIndex = resourceName.LastIndexOf('.');
if (lastDotIndex <= 0) // Either no dot or dot is at the beginning
return resourceName;
// Replace dots before the extension with backslashes
string pathWithoutExtension = resourceName.Substring(0, lastDotIndex).Replace('.', '\\');
string extension = resourceName.Substring(lastDotIndex);
return pathWithoutExtension + extension;
}
}

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<SyntaxDefinition name="HLSL" extensions=".hlsl">
<Environment>
<Default color="Black" bgcolor="#FFFFFF"/>
<Selection color="Black" bgcolor="#C3C3FF"/>
<LineNumbers color="Gray" bgcolor="#FFFFFF"/>
<CaretMarker color="#F0F0F1"/>
<VRuler color="#E0E0E5"/>
<FoldLine color="#A0A0A0" bgcolor="#FFFFFF"/>
<FoldMarker color="Black" bgcolor="#FFFFFF"/>
<SelectedFoldLine color="Black" bgcolor="#FFFFFF"/>
<EOLMarkers color="#CACAD2"/>
<SpaceMarkers color="#B6B6C0"/>
<TabMarkers color="#B6B6C0"/>
<InvalidLines color="#B6B6C0"/>
</Environment>
<Properties>
<Property name="LineComment" value="//"/>
<Property name="BlockCommentBegin" value="/*"/>
<Property name="BlockCommentEnd" value="*/"/>
</Properties>
<Digits name="Number" color="Purple"/>
<RuleSets>
<RuleSet ignorecase="false">
<Delimiters>&amp;&lt;&gt;~%^*()-+=!|\/{}[]:;"' , ?</Delimiters>
<!-- Comments -->
<Span name="LineComment" stopateol="true" color="Green">
<Begin>//</Begin>
</Span>
<Span name="BlockComment" stopateol="false" color="Green">
<Begin>/*</Begin>
<End>*/</End>
</Span>
<!-- Strings -->
<Span name="String" stopateol="false" color="Maroon">
<Begin>"</Begin>
<End>"</End>
</Span>
<!-- Keywords -->
<KeyWords name="Keywords" color="Blue" bold="true">
<Key word="if"/>
<Key word="else"/>
<Key word="for"/>
<Key word="while"/>
<Key word="do"/>
<Key word="break"/>
<Key word="continue"/>
<Key word="return"/>
<Key word="discard"/>
<Key word="struct"/>
<Key word="cbuffer"/>
<Key word="register"/>
<Key word="sampler"/>
<Key word="Texture2D"/>
<Key word="Texture3D"/>
<Key word="TextureCube"/>
<Key word="SamplerState"/>
<Key word="RWTexture2D"/>
</KeyWords>
<!-- Types -->
<KeyWords name="Types" color="Teal">
<Key word="float"/>
<Key word="float2"/>
<Key word="float3"/>
<Key word="float4"/>
<Key word="float4x4"/>
<Key word="int"/>
<Key word="int2"/>
<Key word="int3"/>
<Key word="int4"/>
<Key word="bool"/>
<Key word="bool2"/>
<Key word="bool3"/>
<Key word="bool4"/>
<Key word="uint"/>
<Key word="half"/>
<Key word="min16float"/>
</KeyWords>
</RuleSet>
</RuleSets>
</SyntaxDefinition>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<SyntaxDefinition name="JavaScript" extensions=".js;.jsx;.mjs;.cjs">
<SyntaxDefinition name="JavaScript" extensions=".js;.jsx;.mjs;.cjs;">
<Environment>
<Default color="Black" bgcolor="#FFFFFF"/>

View File

@@ -1,15 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
HTML syntax highlighting
Written by Ezra Altahan
25/10/2016
Version 1.0
hello@exr.be
https://github.com/ei
-->
<SyntaxDefinition name="HTML" extensions=".html;.htm;.xhtml;.shtml;.shtm;.xht;.hta">
<Environment>