fix: tweaking input for make single list to handle star Markdown
All checks were successful
deploy / deploy (push) Successful in 43m31s

This commit is contained in:
D. Moonfire 2024-04-20 21:15:36 -05:00
parent 46f19fd4e8
commit ca9f4867e6
4 changed files with 31 additions and 37 deletions

View file

@ -1,10 +1,10 @@
# MfGames CIL (C# and .NET) Libraries
# MfGames .NET Libraries
This [monorepo](https://en.wikipedia.org/wiki/Monorepo) is the collection of all Moonfire Games's libraries for languages supported by the [Common Intermediate Language](https://en.wikipedia.org/wiki/Common_Intermediate_Language) (CIL), also known as .NET and C#. Some of these libraries have roots back into development since 2001 and they have gone through a number of iterations.
## Documentation
The documentation for the entire project can be found in the [./docs/ folders](./docs/index.md) of this registry, but below are some notable links there.
The documentation for the entire project can be found in the [./docs/ folder](./docs/index.md) of this project, but below are some notable links are:
- [MfGames.Gallium](./docs/gallium/index.md) - A toy Entity-Component-System (ECS) modeled after LINQ methods calls and suitable for environment where ease of use is more critical than performance.
- [MfGames.Nitride](./docs/nitride/index.md) - A flexible, configuration-as-code, static site generator build on top of MfGames.Gallium.

View file

@ -2,37 +2,6 @@
Gallium is a simple [Entity-Component-System](https://en.wikipedia.org/wiki/Entity_component_system) (ECS) written to mimic much of the `System.Linq` namespace in C#. It is focused on less on performance and volume, and more with following established C# patterns to make it easy to use.
## Installation
At the moment, Gallium is not in nuget.org. Instead, it can be downloaded from the MfGames repository by configuring `NuGet.config` to pull the `MfGames.*` packages from [src.mfgames.com](https://src.mfgames.com/):
```xml
<!-- NuGet.config -->
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mfgames.com" value="https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json" protocolVersion="3" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
<packageSource key="mfgames.com">
<package pattern="MfGames.*" />
</packageSource>
</packageSourceMapping>
</configuration>
>
```
There is only one package, `MfGames.Gallium` which can be installed from inside Rider, Visual Studio, or via the `dotnet` command line:
```shell
dotnet add package MfGames.Gallium
```
## Namespace
The bulk of the library is located in the `MfGames.Gallium` namespace.
@ -41,6 +10,12 @@ The bulk of the library is located in the `MfGames.Gallium` namespace.
using MfGames.Gallium;
```
There is only one package, `MfGames.Gallium` which can be installed from inside Rider, Visual Studio, or via the `dotnet` command line:
```shell
dotnet add package MfGames.Gallium
```
## Entities
The primary object of the ECS is the `Entity` class, a flyweight class with little more than an integer identifier and a collection of components.

View file

@ -39,15 +39,16 @@ public class MakeSingleLinkListItems : IOperation
string output = Regex.Replace(
content,
@"- \[\[(?<label>[^\]]+?)\]\](?<post>[^\n]+)\n",
@"(?<item>-|\*) \[\[(?<label>[^\]]+?)\]\](?<post>[^\n]+)\n",
match =>
{
string item = match.Groups["item"].ToString();
string wiki = match.Groups["label"].ToString();
string path = string.Format("/{0}/", this.slugs.ToSlug(wiki.Split('|').First()));
string label = wiki.Split('|').Last();
string after = match.Groups["post"].ToString();
string post = this.RemoveLinks(after);
string value = $"- [{label}{post}]({path})\n";
string value = $"{item} [{label}{post}]({path})\n";
return value;
}
@ -55,14 +56,15 @@ public class MakeSingleLinkListItems : IOperation
output = Regex.Replace(
output,
@"- \[(?<label>[^\]]+?)\]\((?<path>[^\)]+?)\)(?<post>[^\n]+)\n",
@"(?<item>-|\*) \[(?<label>[^\]]+?)\]\((?<path>[^\)]+?)\)(?<post>[^\n]+)\n",
match =>
{
string item = match.Groups["item"].ToString();
string label = match.Groups["label"].ToString();
string path = match.Groups["path"].ToString();
string after = match.Groups["post"].ToString();
string post = this.RemoveLinks(after);
string value = $"- [{label}{post}]({path})\n";
string value = $"{item} [{label}{post}]({path})\n";
return value;
}

View file

@ -47,6 +47,23 @@ public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
Assert.Equal("- [Empty space](link)", content);
}
[Fact]
public void ExtendSingleMarkdownLinkStar()
{
using MarkdownTestContext context = this.CreateContext();
List<Entity> input =
new()
{
new Entity().Set(IsMarkdown.Instance).SetTextContent("* [Empty](link) space"),
};
MakeSingleLinkListItems? op = context.Resolve<MakeSingleLinkListItems>();
IEnumerable<Entity> output = op.Run(input);
string content = output.First().GetTextContentString()!.Trim();
Assert.Equal("* [Empty space](link)", content);
}
[Fact]
public void NoLinksNoChange()
{