From 81e3bcf8a4897b3a9da6f8e50802262c4c4a5266 Mon Sep 17 00:00:00 2001 From: Toine db Date: Sat, 1 Feb 2025 15:55:51 +0100 Subject: [PATCH] renaming to match fields --- .../Models/MarkdownReferenceDefinition.cs | 2 +- .../Models/Segments/PlaceholderSegment.cs | 10 +++++----- src/MarkdownParser/Writer/ViewWriter.cs | 2 +- .../MarkdownParserBlockSegmentsSpecs.cs | 6 +++--- .../MarkdownParser.Test/MarkdownParserSectionsSpecs.cs | 2 +- .../Mocks/BlockComponentSupplier.cs | 2 +- .../Mocks/StringComponentSupplier.cs | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/MarkdownParser/Models/MarkdownReferenceDefinition.cs b/src/MarkdownParser/Models/MarkdownReferenceDefinition.cs index 2c9d50c..8a867f1 100644 --- a/src/MarkdownParser/Models/MarkdownReferenceDefinition.cs +++ b/src/MarkdownParser/Models/MarkdownReferenceDefinition.cs @@ -2,7 +2,7 @@ { public class MarkdownReferenceDefinition { - public string Label { get; set; } + public string PlaceholderId { get; set; } public string Url { get; set; } public string Title { get; set; } public bool IsPlaceholder { get; set; } diff --git a/src/MarkdownParser/Models/Segments/PlaceholderSegment.cs b/src/MarkdownParser/Models/Segments/PlaceholderSegment.cs index a4313d7..e30611d 100644 --- a/src/MarkdownParser/Models/Segments/PlaceholderSegment.cs +++ b/src/MarkdownParser/Models/Segments/PlaceholderSegment.cs @@ -4,21 +4,21 @@ namespace MarkdownParser.Models.Segments { public class PlaceholderSegment : IndicatorSegment { - public string Url { get; } + public string PlaceholderId { get; } public string Title { get; } - public PlaceholderSegment(string url, string title) + public PlaceholderSegment(string placeholderId, string title) : base(SegmentIndicator.Placeholder, SegmentIndicatorPosition.Start) { - Url = url; + PlaceholderId = placeholderId?.ToUpper(); Title = title; HasLiteralContent = !string.IsNullOrWhiteSpace(Title) - && !string.IsNullOrWhiteSpace(Url); + && !string.IsNullOrWhiteSpace(placeholderId); } public override string ToString() { - return Title ?? Url ?? string.Empty; + return Title ?? PlaceholderId ?? string.Empty; } } } \ No newline at end of file diff --git a/src/MarkdownParser/Writer/ViewWriter.cs b/src/MarkdownParser/Writer/ViewWriter.cs index fec2302..6685950 100644 --- a/src/MarkdownParser/Writer/ViewWriter.cs +++ b/src/MarkdownParser/Writer/ViewWriter.cs @@ -60,7 +60,7 @@ public void RegisterReferenceDefinitions(Dictionary reference markdownReferenceDefinition.Add(new MarkdownReferenceDefinition() { IsPlaceholder = referenceDefinition.Value.IsPlaceholder, - Label = referenceDefinition.Value.Label, + PlaceholderId = referenceDefinition.Value.Label, Title = referenceDefinition.Value.Title, Url = referenceDefinition.Value.Url }); diff --git a/test/MarkdownParser.Test/MarkdownParserBlockSegmentsSpecs.cs b/test/MarkdownParser.Test/MarkdownParserBlockSegmentsSpecs.cs index 39c8607..da318b4 100644 --- a/test/MarkdownParser.Test/MarkdownParserBlockSegmentsSpecs.cs +++ b/test/MarkdownParser.Test/MarkdownParserBlockSegmentsSpecs.cs @@ -165,7 +165,7 @@ public void When_parsing_text_with_placeholders_it_should_output_ordered_segment textBlock0!.TextSegments[1].As().Indicator.Should().Be(SegmentIndicator.Placeholder); textBlock0!.TextSegments[1].As().IndicatorPosition.Should().Be(SegmentIndicatorPosition.Start); textBlock0!.TextSegments[1].As().Title.Should().Be("placeholder x"); - textBlock0!.TextSegments[1].As().Url.Should().Be("placeholder x"); + textBlock0!.TextSegments[1].As().PlaceholderId.Should().Be("placeholder x".ToUpper()); textBlock0!.TextSegments[1].As().ToString().Should().Be("placeholder x"); textBlock0!.TextSegments[2].As().Text.Should().Be(" within sentence."); @@ -181,7 +181,7 @@ public void When_parsing_text_with_placeholders_it_should_output_ordered_segment textBlock1!.TextSegments[4].As().Text.Should().Be("separated "); textBlock1!.TextSegments[5].As().Indicator.Should().Be(SegmentIndicator.Placeholder); textBlock1!.TextSegments[5].As().Title.Should().Be("placeholder y"); - textBlock1!.TextSegments[5].As().Url.Should().Be("placeholder y"); + textBlock1!.TextSegments[5].As().PlaceholderId.Should().Be("placeholder y".ToUpper()); textBlock1!.TextSegments[5].As().ToString().Should().Be("placeholder y"); textBlock1!.TextSegments[6].As().Indicator.Should().Be(SegmentIndicator.Italic); textBlock1!.TextSegments[6].As().IndicatorPosition.Should().Be(SegmentIndicatorPosition.End); @@ -195,7 +195,7 @@ public void When_parsing_text_with_placeholders_it_should_output_ordered_segment textBlock2!.TextSegments.Length.Should().Be(1); textBlock2!.TextSegments[0].As().Indicator.Should().Be(SegmentIndicator.Placeholder); textBlock2!.TextSegments[0].As().Title.Should().Be("placeholder z"); - textBlock2!.TextSegments[0].As().Url.Should().Be("placeholder z"); + textBlock2!.TextSegments[0].As().PlaceholderId.Should().Be("placeholder z".ToUpper()); textBlock2!.TextSegments[0].As().ToString().Should().Be("placeholder z"); } } \ No newline at end of file diff --git a/test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs b/test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs index d4f2a2d..e894f4f 100644 --- a/test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs +++ b/test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs @@ -211,7 +211,7 @@ public void When_parsing_reference_definitions_it_should_output_specific_views() mockComponentSupplier.MarkdownReferenceDefinitions.Should().HaveCount(1); mockComponentSupplier.MarkdownReferenceDefinitions[0].IsPlaceholder = false; - mockComponentSupplier.MarkdownReferenceDefinitions[0].Label = "PORTTITOR NON QUAM"; + mockComponentSupplier.MarkdownReferenceDefinitions[0].PlaceholderId = "PORTTITOR NON QUAM"; mockComponentSupplier.MarkdownReferenceDefinitions[0].Title = "lipsum"; mockComponentSupplier.MarkdownReferenceDefinitions[0].Url = "https://lipsum.com/"; } diff --git a/test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs b/test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs index 9974ba2..e5c7f83 100644 --- a/test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs +++ b/test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs @@ -88,7 +88,7 @@ public string CreateReferenceDefinitions() foreach (var markdownReferenceDefinition in MarkdownReferenceDefinitions) { content += $"|{markdownReferenceDefinition.IsPlaceholder}"; - content += $"*{markdownReferenceDefinition.Label}"; + content += $"*{markdownReferenceDefinition.PlaceholderId}"; content += $"*{markdownReferenceDefinition.Title}"; content += $"*{markdownReferenceDefinition.Url}"; } diff --git a/test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs b/test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs index f49615b..27b64c3 100644 --- a/test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs +++ b/test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs @@ -82,7 +82,7 @@ public string CreateReferenceDefinitions() foreach (var markdownReferenceDefinition in MarkdownReferenceDefinitions) { content += $"|{markdownReferenceDefinition.IsPlaceholder}"; - content += $"*{markdownReferenceDefinition.Label}"; + content += $"*{markdownReferenceDefinition.PlaceholderId}"; content += $"*{markdownReferenceDefinition.Title}"; content += $"*{markdownReferenceDefinition.Url}"; }