เรามีความยินดีที่จะแจ้งการเปิดตัว GroupDocs.Markdown for .NET 26.3 ซึ่งพร้อมให้บริการตั้งแต่เดือน มีนาคม 2026. การอัปเดตครั้งสำคัญนี้นำเสนอ API สาธารณะที่ออกแบบใหม่, ตัวเรนเดอร์ Markdown ที่ใช้ DOM แบบกำหนดเอง, การควบคุมรูปแบบ Markdown อย่างเต็มที่, การสนับสนุนแบบ async, และการแก้ไขบั๊กหลายรายการ. นอกจากนี้ยังเพิ่มแพ็กเกจ NuGet ที่ทำงานตาม runtime per‑TFM และการสนับสนุน .NET 8 และ .NET 10.

What’s new in this release

คีย์ ประเภท สรุป
MARKDOWNNET-33 ฟีเจอร์ แยกแพ็กเกจ NuGet เป็นแพ็กเกจ runtime แยกตาม TFM
MARKDOWNNET-31 ฟีเจอร์ เพิ่มการสนับสนุน .NET 8 และ .NET 10
MARKDOWNNET-30 ฟีเจอร์ ตัวเรนเดอร์ Markdown ที่ใช้ DOM แบบกำหนดเอง
MARKDOWNNET-29 ฟีเจอร์ คำเตือนการแปลงและโมเดลข้อผิดพลาดแบบรวม
MARKDOWNNET-28 ฟีเจอร์ เส้นทางรูปภาพแบบ relative และการแทนที่รูปภาพ
MARKDOWNNET-27 ฟีเจอร์ การปรับระดับหัวเรื่องและการสร้าง YAML front matter
MARKDOWNNET-26 ฟีเจอร์ การควบคุมรูปแบบ Markdown และตัวเลือกการเรนเดอร์สเปรดชีต
MARKDOWNNET-25 ฟีเจอร์ การตรวจสอบเอกสารโดยไม่ต้องแปลง
MARKDOWNNET-24 ฟีเจอร์ API แบบ Async
MARKDOWNNET-23 ฟีเจอร์ เมธอดสะดวกแบบ static และการค้นหารูปแบบ
MARKDOWNNET-20 การปรับปรุง ทบทวนและออกแบบ API ใหม่
MARKDOWNNET-8 ฟีเจอร์ สนับสนุนการแทนที่รูปภาพระหว่างการแปลงเป็น Markdown
MARKDOWNNET-35 แก้ไขบั๊ก ปัญหาคุณภาพและการทำงาน

Public API changes

New public types

  • DocumentInfo — เมตาดาต้าเอกสาร (รูปแบบ, จำนวนหน้า, ชื่อเรื่อง, ผู้เขียน, สถานะการเข้ารหัส)
  • MarkdownFlavor — enum สำหรับไดอัลเกต์ Markdown เป้าหมาย (GitHub, CommonMark)
  • IImageSavingHandler — อินเทอร์เฟซสำหรับคอลแบ็กการบันทึกรูปภาพแบบกำหนดเอง
  • IUriSavingHandler — อินเทอร์เฟซสำหรับคอลแบ็กการบันทึก URI แบบกำหนดเอง
  • GroupDocsMarkdownException — ข้อยกเว้นการแปลงทั่วไป
  • InvalidFormatException — รูปแบบไฟล์เสียหายหรือไม่รู้จัก
  • DocumentProtectedException — รหัสผ่านผิดหรือไม่มี

New static methods on MarkdownConverter

  • ToMarkdown(string sourcePath) และ overload ที่รับ LoadOptions/ConvertOptions
  • ToFile(string sourcePath, string outputPath) และ overload
  • GetInfo(string sourcePath) และ overload
  • GetSupportedFormats()
  • เวอร์ชัน Async: ToMarkdownAsync, ToFileAsync, GetInfoAsync

New instance methods on MarkdownConverter

  • GetDocumentInfo()
  • ConvertAsync() และ overload

New properties on ConvertOptions

  • ImageExportStrategy (replaces ExportStrategy)
  • UriExportStrategy
  • HeadingLevelOffset
  • IncludeFrontMatter
  • Flavor
  • MaxColumns, MaxRows, SheetSeparator, IncludeHiddenSheets

New properties on ConvertResult

  • Warnings — คำเตือนการแปลงที่ไม่เป็นอันตราย

New properties on ExportImagesToFileSystemStrategy and CustomImagesStrategy

  • ImagesRelativePath — ควบคุมเส้นทางที่เขียนในอ้างอิงรูปภาพของ Markdown

New methods on CustomImageSavingArgs

  • SetReplacementImage(Stream imageStream) — แทนที่เนื้อหารูปภาพ

Removed types

  • IExportStrategy — ถูกแทนที่โดย IImageExportStrategy และ IUriExportStrategy
  • DocumentConverterOptions — เปลี่ยนชื่อเป็น ConvertOptions
  • DocumentConverterResult — เปลี่ยนชื่อเป็น ConvertResult

Breaking changes

Renamed Types

ก่อน หลัง
DocumentConverterOptions ConvertOptions
DocumentConverterResult ConvertResult

FileFormat Enum

ค่าระดับครอบครัว (FileFormat.WordProcessing, FileFormat.Spreadsheet) ถูกแทนที่ด้วยรูปแบบเฉพาะ (FileFormat.Docx, FileFormat.Xlsx ฯลฯ). รายการใหม่: FileFormat.Txt, FileFormat.Chm.

ConvertOptions and LoadOptions separated

ConvertOptions ไม่ได้สืบทอดจาก LoadOptions อีกต่อไป. รหัสผ่านและคำแนะนำรูปแบบจะอยู่ใน LoadOptions:

var loadOptions = new LoadOptions(FileFormat.Docx) { Password = "secret" };
var convertOptions = new ConvertOptions { HeadingLevelOffset = 1 };
using var converter = new MarkdownConverter("file.docx", loadOptions);
var result = converter.Convert(convertOptions);

Image and URI strategies split

คุณสมบัติ ExportStrategy เดียวถูกแทนที่ด้วยสองคุณสมบัติที่มีประเภทเฉพาะ:

var options = new ConvertOptions
{
    ImageExportStrategy = new ExportImagesToFileSystemStrategy("images"),
    UriExportStrategy = new CustomUriExportStrategy(handler)
};

Delegates replaced with interfaces

CustomImagesStrategy และ CustomUriExportStrategy ตอนนี้รับอินเทอร์เฟซ IImageSavingHandler และ IUriSavingHandler แทนการใช้ delegate callbacks.

LoadOptions.Extension and LoadOptions.MimeType are internal

ใช้ new LoadOptions(FileFormat.Docx) แทนการตั้งค่า Extension หรือ MimeType โดยตรง.

New features

Custom DOM‑Based Markdown Renderer

ไลบรารีไม่ส่งต่อการสร้าง Markdown ไปยังการส่งออกของบุคคลที่สามอีกต่อไป. ตัวเรนเดอร์แบบกำหนดเองจะเดินผ่านโหนดของโมเดลวัตถุเอกสารทีละโหนดและสร้าง Markdown โดยตรง, ให้การควบคุมเต็มที่ในทุกแง่มุมของผลลัพธ์.

เอกสาร Word/PDF/Ebook/Text/CHM จะถูกเรนเดอร์พร้อมการสนับสนุนย่อหน้า, หัวเรื่อง (H1‑H6), ตัวหนา, ตัวเอียง, เส้นขีดฆ่า, โค้ดในบรรทัด, รายการลำดับและไม่มีลำดับที่มีการซ้อนกัน, ตาราง (ไวยากรณ์ pipe ของ GFM หรือ fallback เป็น code block ของ CommonMark), ลิงก์, และรูปภาพ.

สเปรดชีต จะถูกเรนเดอร์ด้วยการเดินผ่านกริดเซลล์ต่อเซลล์, การจัดรูปแบบค่าตามประเภท, ส่วนของแผ่นงาน, การตัดคอลัมน์/แถวพร้อมตัวบ่งชี้จุดไข่ปลา, การกรองแผ่นงานที่ซ่อนอยู่, และตัวคั่นแผ่นงานแบบกำหนดเอง.

Static Convenience Methods

เมธอดการแปลงแบบบรรทัดเดียวที่จัดการการจัดการทรัพยากรโดยอัตโนมัติ:

string md = MarkdownConverter.ToMarkdown("report.docx");
MarkdownConverter.ToFile("report.docx", "report.md");
IReadOnlyList<FileFormat> formats = MarkdownConverter.GetSupportedFormats();

Async API

เวอร์ชัน Async สำหรับเมธอด static และ instance ทั้งหมดพร้อมการสนับสนุน CancellationToken:

string md = await MarkdownConverter.ToMarkdownAsync("report.docx");
await MarkdownConverter.ToFileAsync("large.pdf", "output.md");
DocumentInfo info = await MarkdownConverter.GetInfoAsync("report.docx");

Document Inspection Without Conversion

ดึงเมตาดาต้าเอกสารโดยไม่ต้องทำการแปลงเต็มรูปแบบ:

DocumentInfo info = MarkdownConverter.GetInfo("report.docx");
Console.WriteLine($"{info.FileFormat}, {info.PageCount} pages, by {info.Author}");

Markdown Flavor Control

กำหนดไดอัลเกต์ Markdown เฉพาะ:

var options = new ConvertOptions { Flavor = MarkdownFlavor.GitHub }; // pipe tables, strikethrough
var options = new ConvertOptions { Flavor = MarkdownFlavor.CommonMark }; // tables as code blocks

Spreadsheet Rendering Options

การควบคุมเต็มที่ว่าการเรนเดอร์สเปรดชีตเป็น Markdown ทำอย่างไร:

var options = new ConvertOptions
{
    MaxColumns = 8,
    MaxRows = 50,
    SheetSeparator = "\n---\n",
    IncludeHiddenSheets = false
};

Heading Level Offset and YAML Front Matter

var options = new ConvertOptions
{
    HeadingLevelOffset = 2,       // # Title  ->  ### Title
    IncludeFrontMatter = true     // prepend YAML metadata
};

Conversion Warnings and Unified Error Model

เมธอด Convert() ทั้งหมดตอนนี้จะโยนข้อยกเว้นเมื่อเกิดความล้มเหลว. ConvertResult จะบรรจุคำเตือนที่ไม่เป็นอันตราย:

ConvertResult result = converter.Convert();
foreach (string w in result.Warnings)
    Console.WriteLine(w);  // e.g. "Worksheet 'Data' truncated at 50 rows."

Image Replacement and Relative Paths

แทนที่รูปภาพระหว่างการแปลงและควบคุมการอ้างอิงเส้นทาง:

var strategy = new ExportImagesToFileSystemStrategy("c:/output/images")
{
    ImagesRelativePath = "images"  // ![](images/img-001.png)
};

Table of Contents Rendering

เอกสารที่มีสารบัญจะถูกเรนเดอร์เป็นรายการที่เรียบง่ายแทนการแสดงโค้ดฟิลด์ดิบ:

- Introduction
- 1.  Executive Summary
- 2.  Company Overview

Code example

string md = MarkdownConverter.ToMarkdown("report.docx");
MarkdownConverter.ToFile("report.docx", "report.md");
IReadOnlyList<FileFormat> formats = MarkdownConverter.GetSupportedFormats();

How to get the update

NuGet

อัปเกรดเป็นแพ็กเกจ GroupDocs.Markdown ล่าสุดผ่าน NuGet (เช่น Install-Package GroupDocs.Markdown).

Resources