fix: additional fixes for formatting lists for single entry
Some checks failed
deploy / deploy (push) Has been cancelled
Some checks failed
deploy / deploy (push) Has been cancelled
This commit is contained in:
parent
a08f54ca14
commit
701331772f
2 changed files with 22 additions and 4 deletions
|
@ -39,7 +39,7 @@ public class MakeSingleLinkListItems : IOperation
|
||||||
|
|
||||||
string output = Regex.Replace(
|
string output = Regex.Replace(
|
||||||
content,
|
content,
|
||||||
@"(?<item>-|\*) \[\[(?<label>[^\]]+?)\]\](?<post>[^\n]+)\n",
|
@"(?<item>(:?-|\*)\s+)\[\[(?<label>[^\]]+?)\]\](?<post>[^\n]+)\n",
|
||||||
match =>
|
match =>
|
||||||
{
|
{
|
||||||
string item = match.Groups["item"].ToString();
|
string item = match.Groups["item"].ToString();
|
||||||
|
@ -56,7 +56,7 @@ public class MakeSingleLinkListItems : IOperation
|
||||||
|
|
||||||
output = Regex.Replace(
|
output = Regex.Replace(
|
||||||
output,
|
output,
|
||||||
@"(?<item>-|\*) \[(?<label>[^\]]+?)\]\((?<path>[^\)]+?)\)(?<post>[^\n]+)\n",
|
@"(?<item>(:?-|\*)\s+)\[(?<label>[^\]]+?)\]\((?<path>[^\)]+?)\)(?<post>[^\n]+)\n",
|
||||||
match =>
|
match =>
|
||||||
{
|
{
|
||||||
string item = match.Groups["item"].ToString();
|
string item = match.Groups["item"].ToString();
|
||||||
|
|
|
@ -64,6 +64,24 @@ public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
|
||||||
Assert.Equal("* [Empty space](link)", content);
|
Assert.Equal("* [Empty space](link)", content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ExtendSingleMarkdownLinkSpaces()
|
||||||
|
{
|
||||||
|
// Prettier formats lists like this.
|
||||||
|
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]
|
[Fact]
|
||||||
public void NoLinksNoChange()
|
public void NoLinksNoChange()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue