Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MarkdownParser/Models/MarkdownReferenceDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
10 changes: 5 additions & 5 deletions src/MarkdownParser/Models/Segments/PlaceholderSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion src/MarkdownParser/Writer/ViewWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void RegisterReferenceDefinitions(Dictionary<string, Reference> 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
});
Expand Down
6 changes: 3 additions & 3 deletions test/MarkdownParser.Test/MarkdownParserBlockSegmentsSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void When_parsing_text_with_placeholders_it_should_output_ordered_segment
textBlock0!.TextSegments[1].As<IndicatorSegment>().Indicator.Should().Be(SegmentIndicator.Placeholder);
textBlock0!.TextSegments[1].As<IndicatorSegment>().IndicatorPosition.Should().Be(SegmentIndicatorPosition.Start);
textBlock0!.TextSegments[1].As<PlaceholderSegment>().Title.Should().Be("placeholder x");
textBlock0!.TextSegments[1].As<PlaceholderSegment>().Url.Should().Be("placeholder x");
textBlock0!.TextSegments[1].As<PlaceholderSegment>().PlaceholderId.Should().Be("placeholder x".ToUpper());
textBlock0!.TextSegments[1].As<PlaceholderSegment>().ToString().Should().Be("placeholder x");
textBlock0!.TextSegments[2].As<TextSegment>().Text.Should().Be(" within sentence.");

Expand All @@ -181,7 +181,7 @@ public void When_parsing_text_with_placeholders_it_should_output_ordered_segment
textBlock1!.TextSegments[4].As<TextSegment>().Text.Should().Be("separated ");
textBlock1!.TextSegments[5].As<IndicatorSegment>().Indicator.Should().Be(SegmentIndicator.Placeholder);
textBlock1!.TextSegments[5].As<PlaceholderSegment>().Title.Should().Be("placeholder y");
textBlock1!.TextSegments[5].As<PlaceholderSegment>().Url.Should().Be("placeholder y");
textBlock1!.TextSegments[5].As<PlaceholderSegment>().PlaceholderId.Should().Be("placeholder y".ToUpper());
textBlock1!.TextSegments[5].As<PlaceholderSegment>().ToString().Should().Be("placeholder y");
textBlock1!.TextSegments[6].As<IndicatorSegment>().Indicator.Should().Be(SegmentIndicator.Italic);
textBlock1!.TextSegments[6].As<IndicatorSegment>().IndicatorPosition.Should().Be(SegmentIndicatorPosition.End);
Expand All @@ -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<IndicatorSegment>().Indicator.Should().Be(SegmentIndicator.Placeholder);
textBlock2!.TextSegments[0].As<PlaceholderSegment>().Title.Should().Be("placeholder z");
textBlock2!.TextSegments[0].As<PlaceholderSegment>().Url.Should().Be("placeholder z");
textBlock2!.TextSegments[0].As<PlaceholderSegment>().PlaceholderId.Should().Be("placeholder z".ToUpper());
textBlock2!.TextSegments[0].As<PlaceholderSegment>().ToString().Should().Be("placeholder z");
}
}
2 changes: 1 addition & 1 deletion test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@
parseResult[0].Should().StartWith("textview:Aliquet in luctus in porttitor non quam donec.");
mockComponentSupplier.MarkdownReferenceDefinitions.Should().HaveCount(1);

mockComponentSupplier.MarkdownReferenceDefinitions[0].IsPlaceholder = false;

Check warning on line 213 in test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.

Check warning on line 213 in test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.

Check warning on line 213 in test/MarkdownParser.Test/MarkdownParserSectionsSpecs.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.
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/";
}
Expand Down
2 changes: 1 addition & 1 deletion test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
public string CreateReferenceDefinitions()
{
var content = "referencedefinitions>";
foreach (var markdownReferenceDefinition in MarkdownReferenceDefinitions)

Check warning on line 88 in test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.

Check warning on line 88 in test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.

Check warning on line 88 in test/MarkdownParser.Test/Mocks/BlockComponentSupplier.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.
{
content += $"|{markdownReferenceDefinition.IsPlaceholder}";
content += $"*{markdownReferenceDefinition.Label}";
content += $"*{markdownReferenceDefinition.PlaceholderId}";
content += $"*{markdownReferenceDefinition.Title}";
content += $"*{markdownReferenceDefinition.Url}";
}
Expand Down
2 changes: 1 addition & 1 deletion test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@
public string CreateReferenceDefinitions()
{
var content = "referencedefinitions>";
foreach (var markdownReferenceDefinition in MarkdownReferenceDefinitions)

Check warning on line 82 in test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.

Check warning on line 82 in test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.

Check warning on line 82 in test/MarkdownParser.Test/Mocks/StringComponentSupplier.cs

View workflow job for this annotation

GitHub Actions / build-sample-ci

Dereference of a possibly null reference.
{
content += $"|{markdownReferenceDefinition.IsPlaceholder}";
content += $"*{markdownReferenceDefinition.Label}";
content += $"*{markdownReferenceDefinition.PlaceholderId}";
content += $"*{markdownReferenceDefinition.Title}";
content += $"*{markdownReferenceDefinition.Url}";
}
Expand Down
Loading