Skip to content

Commit 1a78cde

Browse files
authored
Simplify GetSemanticContent: return description when no Address, fall back to GetMarkdown for non-images
1 parent 40821c0 commit 1a78cde

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/Libraries/Microsoft.Extensions.DataIngestion/IngestionDocumentElementExtensions.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
64
namespace Microsoft.Extensions.DataIngestion;
75

86
/// <summary>
@@ -25,19 +23,15 @@ internal static class IngestionDocumentElementExtensions
2523
if (element is IngestionDocumentImage image)
2624
{
2725
string? description = image.AlternativeText ?? image.Text;
28-
if (!string.IsNullOrEmpty(description) && image.Address is not null)
26+
if (!string.IsNullOrEmpty(description))
2927
{
30-
return $"![{description}]({image.Address.OriginalString})";
31-
}
28+
if (image.Address is not null)
29+
{
30+
return $"![{description}]({image.Address.OriginalString})";
31+
}
3232

33-
string? markdown = element.GetMarkdown();
34-
if (string.IsNullOrEmpty(description) && image.Address is null
35-
&& markdown is not null && markdown.Contains("data:", StringComparison.Ordinal))
36-
{
3733
return description;
3834
}
39-
40-
return markdown;
4135
}
4236

4337
return element.GetMarkdown();

0 commit comments

Comments
 (0)