writer = new(buffer.Span);
writer.Append("");
writer.Append("");
writer.Append("");
writer.Append("Simple-Bookmark Widget");
writer.Append("");
writer.Append("");
writer.Append("");
writer.Append("Favorites");
writer.Append("
");
writer.Append("
");
//Start bookmarks list
writer.Append("");
writer.Append("- ");
writer.Append("
");
foreach (BookmarkEntry entry in bookmarks)
{
ReadOnlySpan nameSpan = entry.Name.AsSpan();
nameSpan = nameSpan[..Math.Min(nameSpan.Length, 20)];
writer.Append("- ");
//Enable the built-in bookmarks link (makes it prettier)
writer.Append("");
writer.Append(nameSpan);
writer.Append("");
writer.Append("
");
}
writer.Append("
");
writer.Append(" ");
writer.Append("
");
//Close the document
writer.Append("");
writer.Append("");
int byteCount = Encoding.UTF8.GetByteCount(writer.AsSpan());
using (UnsafeMemoryHandle utf8Buffer = MemoryUtil.UnsafeAllocNearestPage(byteCount, true))
{
//Encode utf8 bytes
Encoding.UTF8.GetBytes(writer.AsSpan(), utf8Buffer.Span);
vms.Write(utf8Buffer.AsSpan(0, byteCount));
}
vms.Seek(0, System.IO.SeekOrigin.Begin);
}
}
}