2025-11-24 15:44:37 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2025-11-24 15:51:08 +08:00
|
|
|
using System.Linq;
|
2025-11-24 15:44:37 +08:00
|
|
|
|
|
|
|
|
namespace SlideCombine
|
|
|
|
|
{
|
|
|
|
|
public class ContentFormatter
|
|
|
|
|
{
|
|
|
|
|
public static string FormatBookmarks(List<BookmarkItem> bookmarks)
|
|
|
|
|
{
|
|
|
|
|
if (bookmarks == null || bookmarks.Count == 0)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
// 添加tableOfContents标记
|
|
|
|
|
sb.AppendLine("tableOfContents:");
|
|
|
|
|
|
|
|
|
|
foreach (var bookmark in bookmarks)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(bookmark.Title))
|
|
|
|
|
{
|
|
|
|
|
// 每行内容顶格
|
|
|
|
|
sb.Append(bookmark.Title.Trim());
|
|
|
|
|
|
|
|
|
|
// 单词和页码之间加"----------"
|
|
|
|
|
if (!string.IsNullOrEmpty(bookmark.Page))
|
|
|
|
|
{
|
|
|
|
|
sb.Append("----------");
|
|
|
|
|
sb.Append(bookmark.Page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 页码后加"<br/>"
|
|
|
|
|
sb.Append("<br/>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加subject标记
|
|
|
|
|
sb.AppendLine();
|
|
|
|
|
sb.Append("subject:");
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-24 15:51:08 +08:00
|
|
|
public static string FormatMetadataDocument(DocumentMetadata metadata)
|
|
|
|
|
{
|
|
|
|
|
if (metadata == null)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
return metadata.ToFormattedString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string CombineFormattedMetadataDocuments(List<DocumentMetadata> documents)
|
|
|
|
|
{
|
|
|
|
|
if (documents == null || documents.Count == 0)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
var combined = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < documents.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var doc = documents[i];
|
|
|
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
|
{
|
|
|
|
|
// 在不同文档内容之间用"<>"分隔
|
|
|
|
|
combined.AppendLine();
|
|
|
|
|
combined.AppendLine("<>");
|
|
|
|
|
combined.AppendLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combined.Append(doc.ToFormattedString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return combined.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-24 15:44:37 +08:00
|
|
|
public static string CombineFormattedContents(List<string> formattedContents)
|
|
|
|
|
{
|
|
|
|
|
if (formattedContents == null || formattedContents.Count == 0)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
var combined = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < formattedContents.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i > 0)
|
|
|
|
|
{
|
|
|
|
|
// 在不同文件内容之间用"<>"分隔
|
|
|
|
|
combined.AppendLine();
|
|
|
|
|
combined.AppendLine("<>");
|
|
|
|
|
combined.AppendLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combined.Append(formattedContents[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return combined.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|