Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Org, AsciiDoc, Typst and more markup, Markdown → PPTX, more LibreOffice formats, and KEPUB for Kobo
KnifeLemonb84c7009925e
diff --git a/README.ko.md b/README.ko.mdindex f6e5d109..255f1c1b 100644--- a/README.ko.md+++ b/README.ko.md@@ -82,14 +82,14 @@| 원본 | 변환 대상 ||---|---|| **이미지**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC; GIMP XCF, 카메라 RAW(CR2, CR3, NEF, ARW, DNG 등)는 읽기 | 위 형식끼리(HEIC⁵), PDF, 크기 조정, 흑백 |-| **벡터**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG² | PDF(벡터), PNG 등 이미지, SVG ↔ SVGZ, PDF → EPS/PS¹ |-| **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ; 합치기, 나누기, 페이지 범위 |-| **문서**: DOCX, DOCM, DOTX, EML · DOC, ODT, RTF, WPS, WPD, Pages 등² | PDF, DOCX, HWPX, EPUB, TXT, HTML |-| **스프레드시트**: XLSX, XLSM, XLS, ODS, CSV, TSV · Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, HWPX, HTML |-| **프레젠테이션**: PPTX, PPTM, POTX, PPSX · PPT, ODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX |+| **벡터**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG, FODG² | PDF(벡터), PNG 등 이미지, SVG ↔ SVGZ, PDF → EPS/PS¹, SVG → EMF, WMF, ODG² |+| **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ, SVG²; 합치기, 나누기, 페이지 범위 |+| **문서**: DOCX, DOCM, DOTX, EML · DOC, ODT, FODT, OTT, RTF, WPS, WPD, Pages, ClarisWorks, MacWrite, T602 등² | PDF, DOCX, HWPX, EPUB, TXT, HTML · ODT, FODT, OTT² |+| **스프레드시트**: XLSX, XLSM, XLS, XLT, ODS, CSV, TSV · OTS, FODS, Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, HWPX, HTML · XLT, OTS² |+| **프레젠테이션**: PPTX, PPTM, POTX, PPSX · PPT, ODP, OTP, FODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX · OTP² || **한글**: HWP, HWPX | PDF, PNG, DOCX, HWPX ↔ HWP, TXT, 마크다운, HTML |-| **텍스트**: TXT, 마크다운, HTML · reStructuredText, LaTeX³ | PDF, DOCX, HWPX, EPUB |-| **전자책**: EPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB 등⁴ | PDF, EPUB, DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ |+| **텍스트**: TXT, 마크다운, HTML · reStructuredText, LaTeX, Org, AsciiDoc, Typst, MediaWiki, DocBook, Jupyter, Textile, man, OPML³ | PDF, DOCX, HWPX, EPUB · 서로 변환, PPTX 슬라이드³ |+| **전자책**: EPUB, KEPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB 등⁴ | PDF, EPUB, KEPUB(코보), DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ || **동영상**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, TS, M2TS, 3GP, OGV, VOB 등 | MP4, WEBM, MOV, MKV, AVI, GIF, MP3, M4A, 720p || **오디오**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR 등 | MP3, M4A, WAV, FLAC, OGG, OPUS, AAC || **압축 파일**: ZIP, 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, ISO, CAB, DMG, ALZ, EGG 등 | 압축 풀기, ZIP, 7Z, TAR, TAR.GZ; 여러 파일 → ZIP 하나 |diff --git a/README.md b/README.mdindex c2f73df1..e2fc096b 100644--- a/README.md+++ b/README.md@@ -82,14 +82,14 @@ Filee shows new releases in its menu and updates itself, keeping your settings a| From | To ||---|---|| **Images**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC; GIMP XCF, camera RAW (CR2, CR3, NEF, ARW, DNG, …) read | any of these (HEIC⁵), PDF, resized, grayscale |-| **Vector**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG² | PDF (vector), PNG and other images, SVG ↔ SVGZ, PDF → EPS/PS¹ |-| **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ; merge, split, page ranges |-| **Documents**: DOCX, DOCM, DOTX, EML · DOC, ODT, RTF, WPS, WPD, Pages, …² | PDF, DOCX, HWPX, EPUB, TXT, HTML |-| **Spreadsheets**: XLSX, XLSM, XLS, ODS, CSV, TSV · Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, HWPX, HTML |-| **Presentations**: PPTX, PPTM, POTX, PPSX · PPT, ODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX |+| **Vector**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG, FODG² | PDF (vector), PNG and other images, SVG ↔ SVGZ, PDF → EPS/PS¹, SVG → EMF, WMF, ODG² |+| **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ, SVG²; merge, split, page ranges |+| **Documents**: DOCX, DOCM, DOTX, EML · DOC, ODT, FODT, OTT, RTF, WPS, WPD, Pages, ClarisWorks, MacWrite, T602, …² | PDF, DOCX, HWPX, EPUB, TXT, HTML · ODT, FODT, OTT² |+| **Spreadsheets**: XLSX, XLSM, XLS, XLT, ODS, CSV, TSV · OTS, FODS, Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, HWPX, HTML · XLT, OTS² |+| **Presentations**: PPTX, PPTM, POTX, PPSX · PPT, ODP, OTP, FODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX · OTP² || **HWP**: HWP, HWPX | PDF, PNG, DOCX, HWPX ↔ HWP, TXT, Markdown, HTML |-| **Text**: TXT, Markdown, HTML · reStructuredText, LaTeX³ | PDF, DOCX, HWPX, EPUB |-| **E-books**: EPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB, …⁴ | PDF, EPUB, DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ |+| **Text**: TXT, Markdown, HTML · reStructuredText, LaTeX, Org, AsciiDoc, Typst, MediaWiki, DocBook, Jupyter, Textile, man, OPML³ | PDF, DOCX, HWPX, EPUB · each other, PPTX slides³ |+| **E-books**: EPUB, KEPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB, …⁴ | PDF, EPUB, KEPUB (Kobo), DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ || **Video**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, TS, M2TS, 3GP, OGV, VOB, … | MP4, WEBM, MOV, MKV, AVI, GIF, MP3, M4A, 720p || **Audio**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR, … | MP3, M4A, WAV, FLAC, OGG, OPUS, AAC || **Archives**: ZIP, 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, ISO, CAB, DMG, ALZ, EGG, … | extract, ZIP, 7Z, TAR, TAR.GZ; any files → one ZIP |diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 9ca8989c..bf380ab1 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -81,14 +81,14 @@| 源格式 | 目标格式 ||---|---|| **图片**:JPG、PNG、WEBP、AVIF、TIFF、BMP、GIF、ICO、ICNS、JPEG XL、JPEG 2000、PSD/PSB、TGA、PPM、HEIC;GIMP XCF、相机 RAW(CR2、CR3、NEF、ARW、DNG 等)仅读取 | 上述格式互转(HEIC⁵)、PDF、缩放、灰度 |-| **矢量图**:SVG、SVGZ、EMF、WMF、AI · EPS、PS¹ · CDR、VSD、CGM、ODG² | PDF(矢量)、PNG 等图片、SVG ↔ SVGZ、PDF → EPS/PS¹ |-| **PDF** | DOCX、HWPX、TXT、PNG、JPG、TIFF、CBZ;合并、拆分、页码范围 |-| **文档**:DOCX、DOCM、DOTX、EML · DOC、ODT、RTF、WPS、WPD、Pages 等² | PDF、DOCX、HWPX、EPUB、TXT、HTML |-| **表格**:XLSX、XLSM、XLS、ODS、CSV、TSV · Numbers、ET² | PDF、XLSX、ODS、CSV、TSV、HWPX、HTML |-| **演示文稿**:PPTX、PPTM、POTX、PPSX · PPT、ODP、Keynote² | PDF、PNG、JPG、DOCX、HWPX |+| **矢量图**:SVG、SVGZ、EMF、WMF、AI · EPS、PS¹ · CDR、VSD、CGM、ODG、FODG² | PDF(矢量)、PNG 等图片、SVG ↔ SVGZ、PDF → EPS/PS¹、SVG → EMF、WMF、ODG² |+| **PDF** | DOCX、HWPX、TXT、PNG、JPG、TIFF、CBZ、SVG²;合并、拆分、页码范围 |+| **文档**:DOCX、DOCM、DOTX、EML · DOC、ODT、FODT、OTT、RTF、WPS、WPD、Pages、ClarisWorks、MacWrite、T602 等² | PDF、DOCX、HWPX、EPUB、TXT、HTML · ODT、FODT、OTT² |+| **表格**:XLSX、XLSM、XLS、XLT、ODS、CSV、TSV · OTS、FODS、Numbers、ET² | PDF、XLSX、ODS、CSV、TSV、HWPX、HTML · XLT、OTS² |+| **演示文稿**:PPTX、PPTM、POTX、PPSX · PPT、ODP、OTP、FODP、Keynote² | PDF、PNG、JPG、DOCX、HWPX · OTP² || **HWP**:HWP、HWPX | PDF、PNG、DOCX、HWPX ↔ HWP、TXT、Markdown、HTML |-| **文本**:TXT、Markdown、HTML · reStructuredText、LaTeX³ | PDF、DOCX、HWPX、EPUB |-| **电子书**:EPUB、MOBI、AZW3、AZW、AZW4、FB2、CBZ、CBR、CB7、HTMLZ、TXTZ · LIT、LRF、CHM、PDB 等⁴ | PDF、EPUB、DOCX、TXT、HTML、HWPX · MOBI、AZW3⁴ |+| **文本**:TXT、Markdown、HTML · reStructuredText、LaTeX、Org、AsciiDoc、Typst、MediaWiki、DocBook、Jupyter、Textile、man、OPML³ | PDF、DOCX、HWPX、EPUB · 互相转换、PPTX 幻灯片³ |+| **电子书**:EPUB、KEPUB、MOBI、AZW3、AZW、AZW4、FB2、CBZ、CBR、CB7、HTMLZ、TXTZ · LIT、LRF、CHM、PDB 等⁴ | PDF、EPUB、KEPUB(Kobo)、DOCX、TXT、HTML、HWPX · MOBI、AZW3⁴ || **视频**⁵:MP4、MOV、MKV、WEBM、AVI、WMV、FLV、MPEG、TS、M2TS、3GP、OGV、VOB 等 | MP4、WEBM、MOV、MKV、AVI、GIF、MP3、M4A、720p || **音频**⁵:MP3、M4A、AAC、WAV、FLAC、OGG、OPUS、WMA、AIFF、AMR 等 | MP3、M4A、WAV、FLAC、OGG、OPUS、AAC || **压缩包**:ZIP、7Z、RAR、TAR、TAR.GZ、TAR.BZ2、TAR.XZ、GZ、ISO、CAB、DMG、ALZ、EGG 等 | 解压、ZIP、7Z、TAR、TAR.GZ;多个文件 → 一个 ZIP |diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex da0fca5f..ae74397a 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -19,12 +19,12 @@ Filee chooses engines automatically. Settings → *Engines* shows their status,| **DOCX writer** | built in | **HWPX (and HWP through rhwp), PDF, HTML, EPUB, MOBI/AZW3, FB2, Markdown, TXT, XLSX, XLS, ODS, CSV, PPTX (+ variants) → DOCX** || PDF text | built in (PdfPig) | **PDF → TXT** (reading order, also two columns; no OCR) || E-mail | built in (MimeKit) | **EML → HTML** (headers + body, inline pictures), **TXT**, **ZIP** (the attachments) |-| **E-books** | built in | **EPUB, MOBI/AZW/AZW3/PRC, FB2, HTMLZ, TXTZ → EPUB, HWPX (→ PDF), TXT, HTML, Markdown, FB2, HTMLZ, TXTZ**; HTML, Markdown, TXT, DOCX → EPUB/FB2/HTMLZ/TXTZ; HTML → TXT; comics CBZ/CBR/CB7/CBT/CBC → PDF, EPUB, CBZ; PDF → CBZ; AZW4 → PDF |+| **E-books** | built in | **EPUB, MOBI/AZW/AZW3/PRC, FB2, HTMLZ, TXTZ → EPUB, HWPX (→ PDF), TXT, HTML, Markdown, FB2, HTMLZ, TXTZ**; HTML, Markdown, TXT, DOCX → EPUB/FB2/HTMLZ/TXTZ; HTML → TXT; comics CBZ/CBR/CB7/CBT/CBC → PDF, EPUB, CBZ; PDF → CBZ; AZW4 → PDF; **EPUB ↔ KEPUB** (Kobo) || CAD (ACadSharp + built-in renderer) | built in (library) | **DWG ↔ DXF**; DWG/DXF → **PDF** (vector), **SVG**, PNG, JPG, WEBP, TIFF, BMP, GIF, ICO, AVIF || rhwp | bundled with the installer (`engines/rhwp`) | HWP/HWPX → PDF, **HWP → HWPX, HWPX → HWP** || Archives (7-Zip) | bundled with the installer (`engines/7zip`, ~2.5 MB) + built-in readers | ZIP, 7Z, RAR, TAR (+ GZ/BZ2/XZ/Z/7Z/LZ), CAB, ISO, DMG, … **→ folder, ZIP, 7Z, TAR, TAR.GZ/BZ2/XZ**; ALZ, EGG, lzip read in-process; "Compress into one archive" for any files |-| LibreOffice + H2Orestart + Java | **optional download** (~420 MB, 1.3 GB on disk) | older and rare formats only: DOC, XLS, PPT, RTF and OpenDocument → PDF and to each other, output as DOCX/ODT/ODS/ODP; HWP/HWPX → DOCX/ODT; read-only formats (see below) → PDF and their kind's editable formats |-| Pandoc | **optional download** (~42 MB, 240 MB on disk) | Markdown ↔ DOCX/ODT/RTF, DOCX/ODT/HTML/RTF → Markdown, HTML ↔ DOCX/ODT, reStructuredText and LaTeX ↔ Markdown/HTML/DOCX/ODT (and → RTF, EPUB, TXT) |+| LibreOffice + H2Orestart + Java | **optional download** (~420 MB, 1.3 GB on disk) | older and rare formats only: DOC, XLS, PPT, RTF and OpenDocument → PDF and to each other, output as DOCX/ODT/ODS/ODP; HWP/HWPX → DOCX/ODT; read-only formats (see below) → PDF and their kind's editable formats; FODT, OpenDocument templates (OTT, OTS, OTP) and XLT out; SVG → EMF/WMF/ODG, a PDF page → SVG |+| Pandoc | **optional download** (~42 MB, 240 MB on disk) | Markdown ↔ DOCX/ODT/RTF, DOCX/ODT/HTML/RTF → Markdown, HTML ↔ DOCX/ODT, markup languages (reStructuredText, LaTeX, Org, AsciiDoc, Typst, MediaWiki, DocBook, Jupyter, Textile, man, OPML) ↔ Markdown/HTML/DOCX/ODT and each other (and → RTF, EPUB, TXT), Markdown and markup → PPTX slides || Ghostscript | **optional download** (~20 MB, 31 MB on disk) | EPS/PS → PDF, PDF → EPS/PS, PostScript-based AI → PDF (images through PDF and PDFium) || FFmpeg | **optional download** (~100 MB, 272 MB on disk) | **all video and audio**: video ↔ video, video → animated GIF or a still frame, audio extraction, audio ↔ audio, GIF and photos → MP4/WEBM/MOV, images → HEIC || Calibre | **optional download** (~216 MB, 660 MB on disk) | rare e-book formats: LIT, LRF, CHM, PDB, PML, RB, SNB, TCR, OEB → EPUB; EPUB → MOBI, AZW3, LIT, LRF, PDB, PML, RB, SNB, TCR |@@ -161,7 +161,7 @@ Not converted: Word charts, SmartArt, equations (kept as text), free-form shapes## Spreadsheets-`SpreadsheetConverter` (engine id `spreadsheet`) converts between XLSX, XLS (also `.xlt`), ODS, CSV and TSV (also+`SpreadsheetConverter` (engine id `spreadsheet`) converts between XLSX, XLS (and XLT templates, read only), ODS, CSV and TSV (also`.tab`) in-process; every format goes through one in-memory workbook (`Office/Sheets/Workbook.cs`) whose cells keepthe text the spreadsheet shows, the value behind it and its Excel number format.@@ -392,6 +392,15 @@ writer, so every e-book also reaches HWPX, PDF and images. The document model isfootnotes, pictures come from the base64 binaries; the XML declaration's encoding (often windows-1251) is used.FB2 output nests sections by heading level.- **HTMLZ / TXTZ** (calibre's zipped formats) are read and written, with their `metadata.opf`.+- **KEPUB** (Kobo, `Ebooks/Kepub.cs`, written from the format's public descriptions): EPUB → KEPUB copies the book+ and changes only the XHTML documents of the spine. Every sentence becomes `<span class="koboSpan"+ id="kobo.P.S">` (P counts the block elements of the chapter, S the sentences in it; a sentence ends at . ! ? …+ followed by a space, or at the full-width 。!?), every picture gets a span of its own, and the body's content+ is wrapped in `<div id="book-columns"><div id="book-inner">`. Scripts, styles, SVG and MathML are left alone; a+ chapter that isn't well-formed XML (after HTML entities such as ` ` became character references) is copied+ unchanged. Files are named `name.kepub.epub`, which tells Kobo devices to use their KEPUB reader. Other formats+ reach KEPUB through EPUB (Markdown → EPUB → KEPUB); KEPUB → EPUB removes the markup again, and a KEPUB is read+ like any EPUB.- **Comics**: CBZ, CBR, CB7, CBT and CBC (a ZIP of CBZ files) are opened with SharpCompress; pages are sortednaturally ("page2" before "page10"). → PDF has one page per picture sized like the picture (JPEGs are embeddedas they are), → EPUB is fixed-layout, → CBZ repacks. PDF → CBZ renders the pages with PDFium at the preset DPI.@@ -466,12 +475,46 @@ bundled with the installer), never a 7-Zip installed on the PC. It runs as a sep- HWP/HWPX import comes from the H2Orestart extension, which is written in Java; Filee points LibreOffice at thedownloaded JRE (`-env:UNO_JAVA_JFW_JREHOME`).- It is the only reader of rarer formats, converted to PDF and to the editable formats of their kind: DOT, Works /- WPS Writer, WordPerfect, Lotus Word Pro, AbiWord, Apple Pages and StarWriter (→ DOCX, ODT, DOC, RTF, TXT, HTML);- WPS Spreadsheets (ET), Apple Numbers and StarCalc (→ XLSX, ODS, XLS, CSV, HTML); Apple Keynote, WPS- Presentation (DPS) and StarImpress / StarDraw (→ PPTX, ODP, PPT); Publisher, CorelDRAW, Visio, CGM and ODG- (→ ODG, SVG, PNG). The `--convert-to` filter follows the application that opens the file (checked against- LibreOffice's filter registry): Publisher, CorelDRAW and Visio open in Draw, CGM in Impress, and "SDA" files- in Draw (.sda) or Impress (.sdd). SVG and PNG export the first page.+ WPS Writer, WordPerfect, Lotus Word Pro, AbiWord, Apple Pages, StarWriter, ClarisWorks / AppleWorks (`.cwk`),+ MacWrite (`.mcw`), T602 (`.602`) and Pocket Word (`.psw`) (→ DOCX, ODT, FODT, OTT, DOC, RTF, TXT, HTML); WPS+ Spreadsheets (ET), Apple Numbers, StarCalc and flat ODS (`.fods`) (→ XLSX, ODS, OTS, XLS, XLT, CSV, HTML); Apple+ Keynote, WPS Presentation (DPS), StarImpress / StarDraw and flat ODP (`.fodp`) (→ PPTX, ODP, OTP, PPT);+ Publisher, CorelDRAW, Visio, CGM, ODG and flat ODG (`.fodg`) (→ ODG, SVG, PNG, EMF, WMF). The `--convert-to`+ filter follows the application that opens the file (checked against LibreOffice's filter registry): Publisher,+ CorelDRAW and Visio open in Draw, CGM in Impress, and "SDA" files in Draw (.sda) or Impress (.sdd). ClarisWorks+ files can also be spreadsheets or drawings; Filee treats them as text documents, the common case. SVG, PNG, EMF+ and WMF export the first page.+- Written only by LibreOffice: FODT (`OpenDocument Text Flat XML`), the OpenDocument templates OTT / OTS / OTP+ (`writer8_template`, `calc8_template`, `impress8_template`) and XLT (`MS Excel 97 Vorlage/Template`). XLT is read+ by the built-in spreadsheet engine like XLS.+- SVG opens in Draw only for EMF, WMF and ODG; the vector engine keeps SVG → PDF and images. PDF opens in Draw+ (`draw_pdf_import`) only for SVG and ODG: Draw's SVG export draws every page of a PDF on top of each other, so Filee+ first copies the first page of the preset's page range into a PDF of its own (PDFsharp). EPS and PS reach SVG+ through Ghostscript's PDF; Draw would only show their preview picture.+- Checked with LibreOffice 26.2.6 (`LibreOfficeFormatTests`): FODT, FODS, FODP, FODG, T602 and SVG inputs, the+ template and FODT outputs, XLT read back by the spreadsheet engine, EMF / WMF headers and the one-page PDF → SVG.+ ClarisWorks, MacWrite and Pocket Word are binary formats without sample files in the repository: only their+ filters (`ClarisWorks`, `MacWrite`, `PocketWord File`, all opening in Writer) were checked in the registry.++## Pandoc++`Office/PandocConverter.cs` runs Pandoc for the markup languages Filee doesn't read itself: reStructuredText,+LaTeX, Org (`.org`), AsciiDoc (`.adoc`, `.asciidoc`), Typst (`.typ`), MediaWiki (`.mediawiki`, `.wiki`),+DocBook (`.dbk`, `.docbook`; written as DocBook 5), Jupyter notebooks (`.ipynb`), Textile (`.textile`), man pages+(`.man`) and OPML (`.opml`). Pandoc 3.12 reads and writes all of them.++- Each converts to and from Markdown, HTML, DOCX and ODT and into each other, and to RTF, EPUB and TXT. Through+ Pandoc's JSON AST they are also read by the HWPX writer, so they reach HWPX, HWP and PDF (HWPX writer → rhwp).+ There is no PDF through Pandoc itself (that would need a TeX or Typst engine).+- Edges into a markup language cost 11, one more than into Markdown, so a route with a Pandoc step in the middle+ (an e-mail's HTML → ? → RTF) stays on Markdown.+- Markdown, reStructuredText, Org, AsciiDoc, Typst, MediaWiki, Textile and notebooks → **PPTX** with Pandoc's+ PowerPoint writer (a slide per heading). These edges cost 20: with LibreOffice's cheap PPTX → PDF, Markdown → PPTX+ → PDF would otherwise beat Markdown → HWPX → PDF.+- Extensions that mean other things are not claimed: man pages only as `.man` (`.1` … `.9` are also rotated logs,+ `app.log.1`), DocBook as `.dbk` / `.docbook`, never every `.xml`.+- DocBook, man pages, OPML, Typst, HTML and LaTeX are written with `--standalone` (a root element, a `.TH` header,+ a preamble), the text formats extract pictures into `<name>_files` next to the result.## DjVudiff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 2828fbba..4c1d571f 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -77,12 +77,12 @@"engine.font.description": "Fonts: TTF, OTF, WOFF, WOFF2 and EOT into each other.","engine.cad.description": "AutoCAD drawings: DWG ↔ DXF, and both to PDF, SVG and PNG.","engine.archive.description": "Extracts ZIP, 7Z, RAR, TAR, ISO and more, and packs ZIP, 7Z or TAR.GZ (7-Zip).",- "engine.ebook.description": "EPUB, MOBI, AZW3, FB2 and comics (CBZ, CBR) to PDF, EPUB, DOCX and text.\nAlso documents to EPUB and PDF to CBZ.",+ "engine.ebook.description": "EPUB, MOBI, AZW3, FB2 and comics (CBZ, CBR) to PDF, EPUB, DOCX and text.\nAlso documents to EPUB, EPUB to KEPUB for Kobo and PDF to CBZ.","engine.ffmpeg.description": "Video and audio: MP4, MOV, MKV, WEBM, MP3, M4A, WAV, FLAC and more.\nAlso extracts sound, makes GIFs and saves images as HEIC.",- "engine.pandoc.description": "Markdown and HTML ↔ ODT and RTF, DOCX → Markdown\nreStructuredText and LaTeX ↔ Markdown, HTML, DOCX and ODT",+ "engine.pandoc.description": "Markdown and HTML ↔ ODT and RTF, DOCX → Markdown\nreStructuredText, LaTeX, Org, AsciiDoc, Typst, MediaWiki, DocBook, Jupyter and more ↔ Markdown, HTML, DOCX and ODT\nMarkdown and Org → PPTX slides","engine.ghostscript.description": "EPS, PostScript and older Illustrator files to PDF and images; PDF to EPS and PS.","engine.calibre.description": "Rare e-book formats (LIT, LRF, CHM, PDB, RB…) and Kindle output (MOBI, AZW3).",- "engine.libreoffice.description": "Reads older and less common formats: DOC, PPT, Pages, Keynote, Numbers, WordPerfect, Publisher, Visio…\nAlso saves as DOC, XLS, PPT, ODT or ODP.",+ "engine.libreoffice.description": "Reads older and less common formats: DOC, PPT, Pages, Keynote, Numbers, WordPerfect, ClarisWorks, Publisher, Visio…\nAlso saves as DOC, XLS, PPT, ODT, ODP, OpenDocument templates and EMF.","profile.images": "Images","profile.pdf": "PDF",@@ -423,9 +423,9 @@"engines.lo_hwp": "Use LibreOffice for HWP·HWPX → PDF","engines.lo_hwp_hint": "Off by default: rhwp usually looks more like 한글.\nTurn it on to compare when rhwp gets a document wrong (overlapping text, misplaced tables).","engines.package.libreoffice.name": "LibreOffice (older and rare formats)",- "engines.package.libreoffice.description": "Needed for old or uncommon formats: DOC·PPT, OpenDocument presentations, WordPerfect, Apple Pages·Numbers·Keynote, Publisher·Visio and more.\nAlso saves as DOC·XLS·PPT·ODT·ODP and makes presentations → PDF more faithful.\nWord, Excel, PowerPoint, PDF and HWP convert without it.",- "engines.package.pandoc.name": "Pandoc (Markdown, LaTeX, ODT)",- "engines.package.pandoc.description": "Adds Markdown and HTML ↔ ODT and RTF, DOCX → Markdown, and reStructuredText and LaTeX.\nMarkdown and HTML → PDF, DOCX and HWPX work without it.",+ "engines.package.libreoffice.description": "Needed for old or uncommon formats: DOC·PPT, OpenDocument presentations, WordPerfect, ClarisWorks·MacWrite, Apple Pages·Numbers·Keynote, Publisher·Visio and more.\nAlso saves as DOC·XLS·PPT·ODT·ODP·EMF and makes presentations → PDF more faithful.\nWord, Excel, PowerPoint, PDF and HWP convert without it.",+ "engines.package.pandoc.name": "Pandoc (Markdown, LaTeX, Org and more)",+ "engines.package.pandoc.description": "Adds Markdown and HTML ↔ ODT and RTF, DOCX → Markdown, and LaTeX, Org, AsciiDoc, Typst, Jupyter and other markup.\nAlso makes PPTX slides from Markdown.\nMarkdown and HTML → PDF, DOCX and HWPX work without it.","engines.package.ghostscript.name": "Ghostscript (EPS and PostScript)","engines.package.ghostscript.description": "EPS, PS and older Illustrator files → PDF and images, PDF or SVG → EPS/PS.\nSVG and PDF-compatible AI files convert without it.","engines.package.ffmpeg.name": "FFmpeg (video and audio)",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex c0074be4..da7cdd62 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -77,12 +77,12 @@"engine.font.description": "글꼴: TTF, OTF, WOFF, WOFF2, EOT를 서로 변환해요.","engine.cad.description": "오토캐드 도면: DWG ↔ DXF, 그리고 둘 다 PDF, SVG, PNG로.","engine.archive.description": "ZIP, 7Z, RAR, TAR, ISO 등을 풀고, ZIP·7Z·TAR.GZ로 묶어요(7-Zip).",- "engine.ebook.description": "EPUB, MOBI, AZW3, FB2, 만화책(CBZ, CBR)을 PDF, EPUB, DOCX, 텍스트로 바꿔요.\n문서는 EPUB으로, PDF는 CBZ로도 만들어요.",+ "engine.ebook.description": "EPUB, MOBI, AZW3, FB2, 만화책(CBZ, CBR)을 PDF, EPUB, DOCX, 텍스트로 바꿔요.\n문서는 EPUB으로, EPUB은 코보용 KEPUB으로, PDF는 CBZ로도 만들어요.","engine.ffmpeg.description": "MP4, MOV, MKV, WEBM, MP3, M4A, WAV, FLAC 등 동영상·오디오를 변환해요.\n소리 추출, GIF 만들기, 이미지 → HEIC도 해요.",- "engine.pandoc.description": "마크다운·HTML ↔ ODT·RTF, DOCX → 마크다운\nreStructuredText·LaTeX ↔ 마크다운·HTML·DOCX·ODT",+ "engine.pandoc.description": "마크다운·HTML ↔ ODT·RTF, DOCX → 마크다운\nreStructuredText·LaTeX·Org·AsciiDoc·Typst·MediaWiki·DocBook·Jupyter 등 ↔ 마크다운·HTML·DOCX·ODT\n마크다운·Org → PPTX 슬라이드","engine.ghostscript.description": "EPS, 포스트스크립트, 예전 일러스트레이터 파일을 PDF와 이미지로, PDF를 EPS·PS로.","engine.calibre.description": "드문 전자책 형식(LIT, LRF, CHM, PDB, RB…)과 킨들용 출력(MOBI, AZW3).",- "engine.libreoffice.description": "DOC, PPT, Pages, Keynote, Numbers, 워드퍼펙트, Publisher, Visio 같은 오래되었거나 드문 형식을 읽어요.\nDOC·XLS·PPT·ODT·ODP로 저장도 해요.",+ "engine.libreoffice.description": "DOC, PPT, Pages, Keynote, Numbers, 워드퍼펙트, ClarisWorks, Publisher, Visio 같은 오래되었거나 드문 형식을 읽어요.\nDOC·XLS·PPT·ODT·ODP, 오픈도큐먼트 서식 파일, EMF로 저장도 해요.","profile.images": "이미지","profile.pdf": "PDF",@@ -423,9 +423,9 @@"engines.lo_hwp": "한글(HWP·HWPX) → PDF는 LibreOffice로 변환","engines.lo_hwp_hint": "보통은 rhwp가 한글과 더 비슷하게 그려서 기본은 꺼져 있어요.\nrhwp 결과가 깨질 때(글자 겹침, 표 어긋남) 켜서 비교해 보세요.","engines.package.libreoffice.name": "LibreOffice (오래되었거나 드문 형식)",- "engines.package.libreoffice.description": "DOC·PPT, 오픈도큐먼트 프레젠테이션, 워드퍼펙트, Apple Pages·Numbers·Keynote, Publisher·Visio 같은 오래되었거나 드문 형식에 필요해요.\nDOC·XLS·PPT·ODT·ODP로 저장하고, 발표 자료 → PDF도 더 정확해져요.\n워드·엑셀·파워포인트·PDF·HWP는 없어도 변환돼요.",- "engines.package.pandoc.name": "Pandoc (마크다운·LaTeX·ODT)",- "engines.package.pandoc.description": "마크다운·HTML ↔ ODT·RTF, DOCX → 마크다운, reStructuredText·LaTeX 변환을 추가해요.\n마크다운·HTML → PDF·DOCX·HWPX는 없어도 돼요.",+ "engines.package.libreoffice.description": "DOC·PPT, 오픈도큐먼트 프레젠테이션, 워드퍼펙트, ClarisWorks·MacWrite, Apple Pages·Numbers·Keynote, Publisher·Visio 같은 오래되었거나 드문 형식에 필요해요.\nDOC·XLS·PPT·ODT·ODP·EMF로 저장하고, 발표 자료 → PDF도 더 정확해져요.\n워드·엑셀·파워포인트·PDF·HWP는 없어도 변환돼요.",+ "engines.package.pandoc.name": "Pandoc (마크다운·LaTeX·Org 등)",+ "engines.package.pandoc.description": "마크다운·HTML ↔ ODT·RTF, DOCX → 마크다운, LaTeX·Org·AsciiDoc·Typst·Jupyter 같은 마크업 변환을 추가해요.\n마크다운으로 PPTX 슬라이드도 만들어요.\n마크다운·HTML → PDF·DOCX·HWPX는 없어도 돼요.","engines.package.ghostscript.name": "Ghostscript (EPS·PostScript)","engines.package.ghostscript.description": "EPS·PS와 예전 일러스트레이터 파일을 PDF·이미지로, PDF·SVG를 EPS·PS로 바꿔요.\nSVG와 PDF 호환 AI 파일은 없어도 돼요.","engines.package.ffmpeg.name": "FFmpeg (동영상·오디오)",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 8ec41bb7..ec1d3dab 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -77,12 +77,12 @@"engine.font.description": "字体:TTF、OTF、WOFF、WOFF2 和 EOT 互相转换。","engine.cad.description": "AutoCAD 图纸:DWG ↔ DXF,并可转为 PDF、SVG 和 PNG。","engine.archive.description": "解压 ZIP、7Z、RAR、TAR、ISO 等,并打包为 ZIP、7Z 或 TAR.GZ(7-Zip)。",- "engine.ebook.description": "EPUB、MOBI、AZW3、FB2 和漫画(CBZ、CBR)转为 PDF、EPUB、DOCX 和文本。\n也能把文档转为 EPUB、把 PDF 转为 CBZ。",+ "engine.ebook.description": "EPUB、MOBI、AZW3、FB2 和漫画(CBZ、CBR)转为 PDF、EPUB、DOCX 和文本。\n也能把文档转为 EPUB、把 EPUB 转为 Kobo 用的 KEPUB、把 PDF 转为 CBZ。","engine.ffmpeg.description": "MP4、MOV、MKV、WEBM、MP3、M4A、WAV、FLAC 等视频和音频。\n还能提取声音、制作 GIF、把图片保存为 HEIC。",- "engine.pandoc.description": "Markdown 和 HTML ↔ ODT、RTF,DOCX → Markdown\nreStructuredText、LaTeX ↔ Markdown、HTML、DOCX、ODT",+ "engine.pandoc.description": "Markdown 和 HTML ↔ ODT、RTF,DOCX → Markdown\nreStructuredText、LaTeX、Org、AsciiDoc、Typst、MediaWiki、DocBook、Jupyter 等 ↔ Markdown、HTML、DOCX、ODT\nMarkdown 和 Org → PPTX 幻灯片","engine.ghostscript.description": "EPS、PostScript 和旧版 Illustrator 文件转为 PDF 和图片;PDF 转为 EPS 和 PS。","engine.calibre.description": "少见的电子书格式(LIT、LRF、CHM、PDB、RB…)以及 Kindle 输出(MOBI、AZW3)。",- "engine.libreoffice.description": "读取较旧或少见的格式,如 DOC、PPT、Pages、Keynote、Numbers、WordPerfect、Publisher、Visio。\n也能保存为 DOC、XLS、PPT、ODT 或 ODP。",+ "engine.libreoffice.description": "读取较旧或少见的格式,如 DOC、PPT、Pages、Keynote、Numbers、WordPerfect、ClarisWorks、Publisher、Visio。\n也能保存为 DOC、XLS、PPT、ODT、ODP、OpenDocument 模板或 EMF。","profile.images": "图片","profile.pdf": "PDF",@@ -423,9 +423,9 @@"engines.lo_hwp": "HWP·HWPX → PDF 使用 LibreOffice","engines.lo_hwp_hint": "默认关闭,rhwp 的排版通常更接近韩文 Hangul。\n某个文档用 rhwp 转换出错(文字重叠、表格错位)时再打开对比。","engines.package.libreoffice.name": "LibreOffice(旧版和少见格式)",- "engines.package.libreoffice.description": "旧的或少见的格式需要它,如 DOC·PPT、OpenDocument 演示文稿、WordPerfect、Apple Pages·Numbers·Keynote、Publisher·Visio。\n也能保存为 DOC·XLS·PPT·ODT·ODP,并让演示文稿 → PDF 更准确。\nWord、Excel、PowerPoint、PDF 和 HWP 不需要它也能转换。",- "engines.package.pandoc.name": "Pandoc(Markdown、LaTeX、ODT)",- "engines.package.pandoc.description": "增加 Markdown 和 HTML ↔ ODT、RTF,DOCX → Markdown,以及 reStructuredText、LaTeX 转换。\nMarkdown 和 HTML → PDF、DOCX、HWPX 无需它。",+ "engines.package.libreoffice.description": "旧的或少见的格式需要它,如 DOC·PPT、OpenDocument 演示文稿、WordPerfect、ClarisWorks·MacWrite、Apple Pages·Numbers·Keynote、Publisher·Visio。\n也能保存为 DOC·XLS·PPT·ODT·ODP·EMF,并让演示文稿 → PDF 更准确。\nWord、Excel、PowerPoint、PDF 和 HWP 不需要它也能转换。",+ "engines.package.pandoc.name": "Pandoc(Markdown、LaTeX、Org 等)",+ "engines.package.pandoc.description": "增加 Markdown 和 HTML ↔ ODT、RTF,DOCX → Markdown,以及 LaTeX、Org、AsciiDoc、Typst、Jupyter 等标记语言转换。\n也能用 Markdown 制作 PPTX 幻灯片。\nMarkdown 和 HTML → PDF、DOCX、HWPX 无需它。","engines.package.ghostscript.name": "Ghostscript(EPS 与 PostScript)","engines.package.ghostscript.description": "EPS、PS 和旧版 Illustrator 文件 → PDF 和图片,PDF 或 SVG → EPS/PS。\nSVG 和兼容 PDF 的 AI 文件无需它即可转换。","engines.package.ffmpeg.name": "FFmpeg(视频和音频)",diff --git a/src/Filee.Core/Formats/FormatRegistry.cs b/src/Filee.Core/Formats/FormatRegistry.csindex 46c2be56..14445328 100644--- a/src/Filee.Core/Formats/FormatRegistry.cs+++ b/src/Filee.Core/Formats/FormatRegistry.cs@@ -40,12 +40,13 @@ public static class FormatRegistrynew("eps", "EPS", FormatCategory.Vector, ["eps", "epsf", "epsi"]),new("ps", "PS", FormatCategory.Vector, ["ps"]),new("ai", "AI", FormatCategory.Vector, ["ai"], Writable: false),- new("emf", "EMF", FormatCategory.Vector, ["emf"], Writable: false),- new("wmf", "WMF", FormatCategory.Vector, ["wmf"], Writable: false),+ new("emf", "EMF", FormatCategory.Vector, ["emf"]),+ new("wmf", "WMF", FormatCategory.Vector, ["wmf"]),new("cdr", "CDR", FormatCategory.Vector, ["cdr"], Writable: false),new("cgm", "CGM", FormatCategory.Vector, ["cgm"], Writable: false),new("vsd", "VSD", FormatCategory.Vector, ["vsd", "vsdx"], Writable: false),new("odg", "ODG", FormatCategory.Vector, ["odg"]),+ new("fodg", "FODG", FormatCategory.Vector, ["fodg"], Writable: false),new("pdf", "PDF", FormatCategory.Pdf, ["pdf"]),@@ -58,6 +59,8 @@ public static class FormatRegistrynew("doc", "DOC", FormatCategory.Document, ["doc"]),new("dot", "DOT", FormatCategory.Document, ["dot"], Writable: false),new("odt", "ODT", FormatCategory.Document, ["odt"]),+ new("fodt", "FODT", FormatCategory.Document, ["fodt"]),+ new("ott", "OTT", FormatCategory.Document, ["ott"]),new("rtf", "RTF", FormatCategory.Document, ["rtf"]),new("wps", "WPS", FormatCategory.Document, ["wps"], Writable: false),new("wpd", "WPD", FormatCategory.Document, ["wpd"], Writable: false),@@ -65,6 +68,10 @@ public static class FormatRegistrynew("abw", "ABW", FormatCategory.Document, ["abw", "zabw"], Writable: false),new("pages", "Pages", FormatCategory.Document, ["pages"], Writable: false),new("sdw", "SDW", FormatCategory.Document, ["sdw"], Writable: false),+ new("cwk", "ClarisWorks", FormatCategory.Document, ["cwk"], Writable: false),+ new("mcw", "MacWrite", FormatCategory.Document, ["mcw"], Writable: false),+ new("602", "T602", FormatCategory.Document, ["602"], Writable: false),+ new("psw", "Pocket Word", FormatCategory.Document, ["psw"], Writable: false),new("pub", "PUB", FormatCategory.Document, ["pub"], Writable: false),new("eml", "EML", FormatCategory.Document, ["eml"], Writable: false),@@ -76,8 +83,11 @@ public static class FormatRegistrynew("xlsx", "XLSX", FormatCategory.Spreadsheet, ["xlsx"]),new("xlsm", "XLSM", FormatCategory.Spreadsheet, ["xlsm"]),new("xltx", "XLTX", FormatCategory.Spreadsheet, ["xltx"]),- new("xls", "XLS", FormatCategory.Spreadsheet, ["xls", "xlt"]),+ new("xls", "XLS", FormatCategory.Spreadsheet, ["xls"]),+ new("xlt", "XLT", FormatCategory.Spreadsheet, ["xlt"]),new("ods", "ODS", FormatCategory.Spreadsheet, ["ods"]),+ new("ots", "OTS", FormatCategory.Spreadsheet, ["ots"]),+ new("fods", "FODS", FormatCategory.Spreadsheet, ["fods"], Writable: false),new("csv", "CSV", FormatCategory.Spreadsheet, ["csv"]),new("tsv", "TSV", FormatCategory.Spreadsheet, ["tsv", "tab"]),new("et", "ET", FormatCategory.Spreadsheet, ["et"], Writable: false),@@ -91,6 +101,8 @@ public static class FormatRegistrynew("ppsx", "PPSX", FormatCategory.Presentation, ["ppsx"]),new("ppt", "PPT", FormatCategory.Presentation, ["ppt", "pps", "pot"]),new("odp", "ODP", FormatCategory.Presentation, ["odp"]),+ new("otp", "OTP", FormatCategory.Presentation, ["otp"]),+ new("fodp", "FODP", FormatCategory.Presentation, ["fodp"], Writable: false),new("key", "Keynote", FormatCategory.Presentation, ["key"], Writable: false),new("dps", "DPS", FormatCategory.Presentation, ["dps"], Writable: false),new("sda", "SDA", FormatCategory.Presentation, ["sda", "sdd"], Writable: false),@@ -101,9 +113,21 @@ public static class FormatRegistrynew("html", "HTML", FormatCategory.Text, ["html", "htm", "xhtml"]),new("rst", "reStructuredText", FormatCategory.Text, ["rst"]),new("tex", "LaTeX", FormatCategory.Text, ["tex", "latex"]),+ // Read and written by Pandoc. Man pages claim only ".man": the section numbers (.1 … .9) are also the+ // extensions of rotated logs ("app.log.1"). DocBook claims ".dbk", not every ".xml".+ new("org", "Org", FormatCategory.Text, ["org"]),+ new("adoc", "AsciiDoc", FormatCategory.Text, ["adoc", "asciidoc"]),+ new("typ", "Typst", FormatCategory.Text, ["typ"]),+ new("mediawiki", "MediaWiki", FormatCategory.Text, ["mediawiki", "wiki"]),+ new("dbk", "DocBook", FormatCategory.Text, ["dbk", "docbook"]),+ new("ipynb", "Jupyter", FormatCategory.Text, ["ipynb"]),+ new("textile", "Textile", FormatCategory.Text, ["textile"]),+ new("man", "Man page", FormatCategory.Text, ["man"]),+ new("opml", "OPML", FormatCategory.Text, ["opml"]),// E-booksnew("epub", "EPUB", FormatCategory.Ebook, ["epub"]),+ new("kepub", "KEPUB", FormatCategory.Ebook, ["kepub.epub", "kepub"]),new("mobi", "MOBI", FormatCategory.Ebook, ["mobi"]),new("azw3", "AZW3", FormatCategory.Ebook, ["azw3"]),new("azw", "AZW", FormatCategory.Ebook, ["azw"], Writable: false),diff --git a/src/Filee.Core/Presets/BuiltInData.cs b/src/Filee.Core/Presets/BuiltInData.csindex 65fab5c3..20510abc 100644--- a/src/Filee.Core/Presets/BuiltInData.cs+++ b/src/Filee.Core/Presets/BuiltInData.cs@@ -112,6 +112,7 @@ public static class BuiltInDatanew() { Id = "to-epub", Name = "EPUB", TargetFormat = "epub" },new() { Id = "to-mobi", Name = "MOBI", TargetFormat = "mobi" },new() { Id = "to-azw3", Name = "AZW3", TargetFormat = "azw3" },+ new() { Id = "to-kepub", Name = "KEPUB", TargetFormat = "kepub" },new() { Id = "to-fb2", Name = "FB2", TargetFormat = "fb2" },new() { Id = "to-cbz", Name = "CBZ", TargetFormat = "cbz" },@@ -237,7 +238,7 @@ public static class BuiltInData{Id = "ebooks", NameKey = "profile.ebooks",Extensions = ExtensionsOf(FormatCategory.Ebook),- PresetIds = ["to-pdf", "to-epub", "to-docx", "to-txt", "to-azw3", "to-mobi", "to-hwpx", "to-hwp", "to-html"],+ PresetIds = ["to-pdf", "to-epub", "to-docx", "to-txt", "to-azw3", "to-mobi", "to-kepub", "to-hwpx", "to-hwp", "to-html"],},new(){diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.csindex 7e4f98ea..4df29b84 100644--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@ -50,7 +50,7 @@ public sealed class DonutSettingspublic sealed class AppSettings{/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>- public const int CurrentSchemaVersion = 10;+ public const int CurrentSchemaVersion = 11;public int SchemaVersion { get; set; } = CurrentSchemaVersion;diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.csindex ae92ef14..9f4be7fe 100644--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@ -360,21 +360,32 @@ internal static class SettingsMigrationspresets.Add(BuiltInData.CreatePresets().Single(p => p.Id == "remove-background"));changed = true;}++ // v11: more document formats (Org, AsciiDoc, Typst, ... through Pandoc; flat OpenDocument, templates,+ // ClarisWorks, ... through LibreOffice; KEPUB built in). Built-in donuts learn the new extensions unless+ // another donut already has them, and the e-books donut gets KEPUB after MOBI.+ if (from < 11)+ {+ if (presets.All(p => p.Id != "to-kepub"))+ {+ presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == "to-kepub"));+ changed = true;+ changed |= Offer(presets, profiles, "ebooks", "to-kepub", "to-mobi");+ }+ changed |= LearnExtensions(profiles, out _);+ }return changed;}- private static bool AddCatalog(List<Preset> presets, List<ToolbarProfile> profiles)+ /// <summary>+ /// Adds the default extensions of the built-in donuts that no donut of the user takes yet.+ /// </summary>+ /// <param name="claimed">Every extension a donut takes afterwards.</param>+ private static bool LearnExtensions(List<ToolbarProfile> profiles, out HashSet<string> claimed){var changed = false;- foreach (var preset in BuiltInData.CatalogPresets().Where(p => presets.All(existing => existing.Id != p.Id)))- {- presets.Add(preset);- changed = true;- }- var presetIds = presets.Select(p => p.Id).ToHashSet();-// Extensions checked on a mixed-selection profile only limit that profile; they don't claim files.- var claimed = profiles.Where(p => !p.IsFallback).SelectMany(p => p.Extensions).ToHashSet(StringComparer.OrdinalIgnoreCase);+ claimed = profiles.Where(p => !p.IsFallback).SelectMany(p => p.Extensions).ToHashSet(StringComparer.OrdinalIgnoreCase);var defaults = BuiltInData.CreateProfiles().ToDictionary(p => p.Id);foreach (var profile in profiles.Where(p => !p.IsFallback && defaults.ContainsKey(p.Id))){@@ -384,6 +395,19 @@ internal static class SettingsMigrationschanged = true;}}+ return changed;+ }++ private static bool AddCatalog(List<Preset> presets, List<ToolbarProfile> profiles)+ {+ var changed = false;+ foreach (var preset in BuiltInData.CatalogPresets().Where(p => presets.All(existing => existing.Id != p.Id)))+ {+ presets.Add(preset);+ changed = true;+ }+ var presetIds = presets.Select(p => p.Id).ToHashSet();+ changed |= LearnExtensions(profiles, out var claimed);var text = profiles.FindIndex(p => p.Id == "text");var insertAt = text >= 0 ? text + 1 : profiles.FindIndex(p => p.IsFallback);diff --git a/src/Filee.Engines/Ebooks/EbookConverter.cs b/src/Filee.Engines/Ebooks/EbookConverter.csindex 3c420bbc..c32e11a9 100644--- a/src/Filee.Engines/Ebooks/EbookConverter.cs+++ b/src/Filee.Engines/Ebooks/EbookConverter.cs@@ -1,7 +1,8 @@// Built-in e-book conversions, no external program: EPUB, MOBI / AZW / AZW3 / PRC, FB2, HTMLZ and TXTZ are read into// the HWPX document model and written as EPUB, HWPX (→ PDF / images through rhwp and PDFium), TXT, HTML, Markdown,// FB2, HTMLZ or TXTZ; HTML, Markdown, TXT and DOCX become e-books too. Comics (CBZ / CBR / CB7 / CBT / CBC) become-// PDF, fixed-layout EPUB or CBZ, PDF becomes CBZ, and AZW4 (Print Replica) gives back its PDF.+// PDF, fixed-layout EPUB or CBZ, PDF becomes CBZ, and AZW4 (Print Replica) gives back its PDF. EPUB ↔ KEPUB (Kobo)+// adds or removes Kobo's sentence markup and keeps the rest of the book as it is.// Formats only calibre reads or writes (LIT, LRF, PDB, MOBI / AZW3 output, ...) are in CalibreConverter.using System.Text;@@ -16,7 +17,7 @@ namespace Filee.Engines.Ebooks;public sealed class EbookConverter : IConverter{/// <summary>E-book formats read into the document model.</summary>- private static readonly string[] BookReaders = ["epub", "mobi", "azw3", "azw", "prc", "fb2", "htmlz", "txtz"];+ private static readonly string[] BookReaders = ["epub", "kepub", "mobi", "azw3", "azw", "prc", "fb2", "htmlz", "txtz"];/// <summary>Formats written from the document model.</summary>private static readonly string[] BookWriters = ["epub", "hwpx", "txt", "html", "md", "fb2", "htmlz", "txtz"];@@ -34,7 +35,12 @@ public sealed class EbookConverter : IConverterpublic IReadOnlyList<ConversionEdge> Edges { get; } =[- .. BookReaders.SelectMany(from => BookWriters.Where(to => to != from).Select(to => new ConversionEdge(from, to, to == "md" ? 12 : 10))),+ // KEPUB → EPUB is below: the book is copied without Kobo's markup instead of being written anew.+ .. BookReaders.SelectMany(from => BookWriters.Where(to => to != from && !(from == "kepub" && to == "epub"))+ .Select(to => new ConversionEdge(from, to, to == "md" ? 12 : 10))),+ // Every other format reaches KEPUB through EPUB.+ new("epub", "kepub"),+ new("kepub", "epub"),.. DocumentReaders.SelectMany(from => EbookWriters.Select(to => new ConversionEdge(from, to))),// HTML → TXT has no other built-in route; HTML → Markdown is a fallback for when Pandoc is not installed.new("html", "txt"),@@ -46,7 +52,7 @@ public sealed class EbookConverter : IConverternew("azw4", "pdf"),];- public EngineStatus GetStatus() => EngineStatus.Available("EPUB, MOBI / AZW3, FB2, HTMLZ, TXTZ, CBZ / CBR / CB7 / CBT / CBC, AZW4",+ public EngineStatus GetStatus() => EngineStatus.Available("EPUB, KEPUB, MOBI / AZW3, FB2, HTMLZ, TXTZ, CBZ / CBR / CB7 / CBT / CBC, AZW4",$"{EngineVersions.BuiltIn} · {EngineVersions.Library("AngleSharp", typeof(AngleSharp.BrowsingContext))}");public Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken) =>@@ -68,6 +74,18 @@ public sealed class EbookConverter : IConverterprogress?.Report(1);return [target];}+ if (step.To == "kepub" || step.From == "kepub" && step.To == "epub")+ {+ var target = step.Output.Allocate(Filee.Core.Formats.FormatRegistry.Get(step.To).PrimaryExtension);+ if (target is null)+ return [];+ if (step.To == "kepub")+ Kepub.FromEpub(step.InputPath, target, cancellationToken);+ else+ Kepub.ToEpub(step.InputPath, target, cancellationToken);+ progress?.Report(1);+ return [target];+ }var book = Read(step, work, cancellationToken);progress?.Report(0.5);@@ -86,7 +104,7 @@ public sealed class EbookConverter : IConvertervar media = Path.Combine(work, "media");switch (step.From){- case "epub":+ case "epub" or "kepub":return EpubReader.ReadBook(input, work, cancellationToken);case "mobi" or "azw3" or "azw" or "prc":return MobiReader.ReadBook(input, work, cancellationToken);diff --git a/src/Filee.Engines/Ebooks/Kepub.cs b/src/Filee.Engines/Ebooks/Kepub.csnew file mode 100644index 00000000..9f583f08--- /dev/null+++ b/src/Filee.Engines/Ebooks/Kepub.cs@@ -0,0 +1,384 @@+// KEPUB, the EPUB flavour Kobo e-readers read with their own engine (page turns, reading statistics, highlights):+// an EPUB whose XHTML chapters mark every sentence as <span class="koboSpan" id="kobo.P.S">, P counting the+// paragraphs (block elements) of the chapter and S the sentences in it; pictures get a span of their own. The body's+// content is wrapped in <div id="book-columns"><div id="book-inner">, which Kobo's reader styles. Files are named+// "name.kepub.epub" so Kobo devices pick the KEPUB engine when they are copied over USB.+//+// Written from the public descriptions of the format (MobileRead wiki, kepubify's documentation). EPUB → KEPUB+// changes only the spine's XHTML documents; every other file of the book (styles, fonts, pictures, the package+// document) is copied unchanged. KEPUB → EPUB removes the markup again.++using System.IO.Compression;+using System.Net;+using System.Text;+using System.Text.RegularExpressions;+using System.Xml;+using System.Xml.Linq;++namespace Filee.Engines.Ebooks;++internal static partial class Kepub+{+ private const string SpanClass = "koboSpan";+ private const string ColumnsId = "book-columns";+ private const string InnerId = "book-inner";++ /// <summary>Elements whose text is not reading text.</summary>+ private static readonly HashSet<string> Skipped = new(StringComparer.OrdinalIgnoreCase)+ {+ "script", "style", "textarea", "select", "option", "noscript", "head", "title",+ };++ /// <summary>Elements that start a new paragraph number.</summary>+ private static readonly HashSet<string> Blocks = new(StringComparer.OrdinalIgnoreCase)+ {+ "body", "p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "ol", "ul", "dl", "dt", "dd", "blockquote", "pre",+ "td", "th", "tr", "table", "caption", "figure", "figcaption", "section", "article", "aside", "header", "footer",+ "nav", "address", "main", "hr",+ };++ /// <summary>Copies an EPUB as a KEPUB.</summary>+ public static void FromEpub(string epub, string output, CancellationToken cancellationToken) =>+ Rewrite(epub, output, AddSpans, cancellationToken);++ /// <summary>Copies a KEPUB as a plain EPUB without Kobo's markup.</summary>+ public static void ToEpub(string kepub, string output, CancellationToken cancellationToken) =>+ Rewrite(kepub, output, RemoveSpans, cancellationToken);++ /// <summary>+ /// Copies the book, passing each XHTML document of the spine through <paramref name="transform"/> (which returns+ /// false to keep it as it was). "mimetype" is written first and stored, as EPUB requires.+ /// </summary>+ private static void Rewrite(string input, string output, Func<XDocument, bool> transform, CancellationToken cancellationToken)+ {+ using var source = OpenZip(input);+ EpubReader.CheckDrm(source);+ var documents = ContentDocuments(source);++ using var stream = File.Create(output);+ using var target = new ZipArchive(stream, ZipArchiveMode.Create);+ var mimetype = target.CreateEntry("mimetype", CompressionLevel.NoCompression);+ using (var writer = mimetype.Open())+ writer.Write("application/epub+zip"u8);++ foreach (var entry in source.Entries)+ {+ cancellationToken.ThrowIfCancellationRequested();+ if (entry.FullName == "mimetype" || entry.FullName.EndsWith('/'))+ continue;+ var copy = target.CreateEntry(entry.FullName, CompressionLevel.Optimal);+ copy.LastWriteTime = entry.LastWriteTime;+ byte[]? rewritten = null;+ if (documents.Contains(entry.FullName))+ {+ using var read = entry.Open();+ var bytes = ReadAll(read);+ if (Load(bytes) is { } document && transform(document))+ rewritten = Save(document);+ rewritten ??= bytes;+ }+ using var write = copy.Open();+ if (rewritten is not null)+ {+ write.Write(rewritten);+ }+ else+ {+ using var read = entry.Open();+ read.CopyTo(write);+ }+ }+ }++ private static ZipArchive OpenZip(string path)+ {+ try+ {+ return ZipFile.OpenRead(path);+ }+ catch (InvalidDataException ex)+ {+ throw new InvalidDataException("This is not a valid EPUB file (it is not a ZIP package).", ex);+ }+ }++ // ───────────────────────── Package ─────────────────────────++ /// <summary>+ /// ZIP entry names of the XHTML documents in the spine (container.xml → package document); every .xhtml / .html+ /// file when the package can't be read.+ /// </summary>+ internal static HashSet<string> ContentDocuments(ZipArchive zip)+ {+ var names = new HashSet<string>(StringComparer.Ordinal);+ if (PackagePath(zip) is { } opfPath && zip.GetEntry(opfPath) is { } opfEntry && LoadEntry(opfEntry) is { Root: { } package })+ {+ var folder = opfPath.Contains('/') ? opfPath[..(opfPath.LastIndexOf('/') + 1)] : "";+ var manifest = new Dictionary<string, (string Path, string MediaType)>(StringComparer.Ordinal);+ foreach (var item in package.Descendants().Where(e => e.Name.LocalName == "item"))+ {+ if ((string?)item.Attribute("id") is { } id && (string?)item.Attribute("href") is { } href+ && Resolve(folder, Uri.UnescapeDataString(href.Split('#')[0])) is { } path)+ manifest.TryAdd(id, (path, ((string?)item.Attribute("media-type") ?? "").Trim().ToLowerInvariant()));+ }+ foreach (var itemRef in package.Descendants().Where(e => e.Name.LocalName == "itemref"))+ {+ if ((string?)itemRef.Attribute("idref") is { } idRef && manifest.TryGetValue(idRef, out var item)+ && (item.MediaType is "application/xhtml+xml" or "text/html" || IsHtmlName(item.Path)))+ names.Add(item.Path);+ }+ }+ if (names.Count == 0)+ names.UnionWith(zip.Entries.Select(e => e.FullName).Where(IsHtmlName));+ return names;+ }++ private static bool IsHtmlName(string name) =>+ name.EndsWith(".xhtml", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".html", StringComparison.OrdinalIgnoreCase)+ || name.EndsWith(".htm", StringComparison.OrdinalIgnoreCase);++ private static string? PackagePath(ZipArchive zip)+ {+ if (zip.GetEntry("META-INF/container.xml") is { } container && LoadEntry(container) is { } document+ && document.Descendants().FirstOrDefault(e => e.Name.LocalName == "rootfile") is { } rootFile+ && (string?)rootFile.Attribute("full-path") is { Length: > 0 } fullPath)+ return Uri.UnescapeDataString(fullPath).TrimStart('/');+ return zip.Entries.FirstOrDefault(e => e.FullName.EndsWith(".opf", StringComparison.OrdinalIgnoreCase))?.FullName;+ }++ /// <summary>"OEBPS/" + "../Text/ch1.xhtml" → "Text/ch1.xhtml"; null when it leaves the book.</summary>+ internal static string? Resolve(string folder, string href)+ {+ var parts = new List<string>();+ foreach (var part in (folder + href).Replace('\\', '/').Split('/'))+ {+ if (part is "" or ".")+ continue;+ if (part == "..")+ {+ if (parts.Count == 0)+ return null;+ parts.RemoveAt(parts.Count - 1);+ }+ else+ {+ parts.Add(part);+ }+ }+ return parts.Count == 0 ? null : string.Join('/', parts);+ }++ private static XDocument? LoadEntry(ZipArchiveEntry entry)+ {+ using var stream = entry.Open();+ return Load(ReadAll(stream));+ }++ // ───────────────────────── XML ─────────────────────────++ private static byte[] ReadAll(Stream stream)+ {+ using var memory = new MemoryStream();+ stream.CopyTo(memory);+ return memory.ToArray();+ }++ /// <summary>+ /// Parses an XHTML document with its whitespace. HTML entities that XML does not define (&nbsp; …) become+ /// character references first; external DTDs are never loaded. Null when it is not well-formed XML.+ /// </summary>+ internal static XDocument? Load(byte[] bytes)+ {+ string text;+ using (var reader = new StreamReader(new MemoryStream(bytes), Encoding.UTF8, detectEncodingFromByteOrderMarks: true))+ text = reader.ReadToEnd();+ text = NamedEntity().Replace(text, match =>+ {+ if (match.Groups[1].Value is "amp" or "lt" or "gt" or "quot" or "apos")+ return match.Value;+ var decoded = WebUtility.HtmlDecode(match.Value);+ if (decoded == match.Value)+ return match.Value;+ var references = new StringBuilder();+ for (var i = 0; i < decoded.Length; i += char.IsSurrogatePair(decoded, i) ? 2 : 1)+ references.Append("&#x").Append(char.ConvertToUtf32(decoded, i).ToString("X")).Append(';');+ return references.ToString();+ });+ var settings = new XmlReaderSettings+ {+ DtdProcessing = DtdProcessing.Parse, // keeps the DOCTYPE; nothing is fetched without a resolver+ XmlResolver = null,+ MaxCharactersFromEntities = 1_000_000,+ };+ try+ {+ using var reader = XmlReader.Create(new StringReader(text), settings);+ return XDocument.Load(reader, LoadOptions.PreserveWhitespace);+ }+ catch (XmlException)+ {+ return null;+ }+ }++ private static byte[] Save(XDocument document)+ {+ using var memory = new MemoryStream();+ var settings = new XmlWriterSettings { Encoding = new UTF8Encoding(false), Indent = false };+ using (var writer = XmlWriter.Create(memory, settings))+ document.Save(writer);+ return memory.ToArray();+ }++ [GeneratedRegex(@"&([A-Za-z][A-Za-z0-9]{1,31});")]+ private static partial Regex NamedEntity();++ // ───────────────────────── Kobo spans ─────────────────────────++ /// <summary>Adds Kobo's sentence spans and wrapper divs. False for a document that has them already.</summary>+ internal static bool AddSpans(XDocument document)+ {+ if (document.Root?.Descendants().FirstOrDefault(e => e.Name.LocalName == "body") is not { } body+ || document.Root.Descendants().Any(IsKoboSpan))+ return false;+ var ns = body.Name.Namespace;+ var state = new SpanState(ns);+ Visit(body, state);++ var inner = new XElement(ns + "div", new XAttribute("id", InnerId), body.Nodes().ToList());+ body.RemoveNodes();+ body.Add(new XElement(ns + "div", new XAttribute("id", ColumnsId), inner));+ return true;+ }++ private sealed class SpanState(XNamespace ns)+ {+ public XNamespace Namespace { get; } = ns;+ public XElement? Block { get; set; }+ public int Paragraph { get; set; }+ public int Sentence { get; set; }++ /// <summary>A new span id, starting a new paragraph number when <paramref name="block"/> changed.</summary>+ public string NextId(XElement block)+ {+ if (!ReferenceEquals(block, Block))+ {+ Block = block;+ Paragraph++;+ Sentence = 0;+ }+ Sentence++;+ return $"kobo.{Paragraph}.{Sentence}";+ }+ }++ private static void Visit(XElement element, SpanState state)+ {+ foreach (var node in element.Nodes().ToList())+ {+ switch (node)+ {+ case XText text when text.Value.Trim().Length > 0:+ Wrap(text, state);+ break;+ case XElement child when child.Name.Namespace != state.Namespace || Skipped.Contains(child.Name.LocalName):+ break; // SVG, MathML, scripts, ...+ case XElement child when child.Name.LocalName.Equals("img", StringComparison.OrdinalIgnoreCase):+ child.ReplaceWith(Span(state, BlockOf(child), child));+ break;+ case XElement child:+ Visit(child, state);+ break;+ }+ }+ }++ /// <summary>Replaces a text node with one span per sentence (whitespace before the first stays outside).</summary>+ private static void Wrap(XText text, SpanState state)+ {+ var value = text.Value;+ var start = 0;+ while (start < value.Length && char.IsWhiteSpace(value[start]))+ start++;+ var block = BlockOf(text);+ var nodes = new List<XNode>();+ if (start > 0)+ nodes.Add(new XText(value[..start]));+ foreach (var sentence in Sentences(value[start..]))+ nodes.Add(Span(state, block, new XText(sentence)));+ text.ReplaceWith(nodes);+ }++ private static XElement Span(SpanState state, XElement block, XNode content) =>+ new(state.Namespace + "span", new XAttribute("class", SpanClass), new XAttribute("id", state.NextId(block)), content);++ private static XElement BlockOf(XNode node)+ {+ var parent = node.Parent!;+ while (!Blocks.Contains(parent.Name.LocalName) && parent.Parent is { } up)+ parent = up;+ return parent;+ }++ /// <summary>+ /// Splits text after sentence ends: . ! ? … (with closing quotes and brackets) followed by whitespace, which+ /// stays with the sentence, and the full-width 。!? of Chinese and Japanese, which need no space.+ /// </summary>+ internal static IEnumerable<string> Sentences(string text)+ {+ var start = 0;+ var i = 0;+ while (i < text.Length)+ {+ var c = text[i];+ if (c is not ('.' or '!' or '?' or '…' or '。' or '!' or '?'))+ {+ i++;+ continue;+ }+ var end = i + 1;+ while (end < text.Length && (text[end] is '.' or '!' or '?' or '…' or '。' or '!' or '?'+ || text[end] is '"' or '\'' or ')' or ']' or '”' or '’' or '」' or '』' or ')'))+ end++;+ var wide = c is '。' or '!' or '?';+ if (end < text.Length && char.IsWhiteSpace(text[end]))+ {+ while (end < text.Length && char.IsWhiteSpace(text[end]))+ end++;+ }+ else if (!wide)+ {+ i = end;+ continue; // "3.14", "e.g.x", an ellipsis inside a sentence+ }+ if (end < text.Length)+ {+ yield return text[start..end];+ start = end;+ }+ i = end;+ }+ if (start < text.Length)+ yield return text[start..];+ }++ // ───────────────────────── Back to EPUB ─────────────────────────++ /// <summary>Removes Kobo's spans and wrapper divs. False when there are none.</summary>+ internal static bool RemoveSpans(XDocument document)+ {+ if (document.Root is not { } root)+ return false;+ // Innermost first: ReplaceWith copies the children, so an outer element must go after the ones inside it.+ var markup = root.Descendants().Where(e => IsKoboSpan(e) || IsWrapper(e)).Reverse().ToList();+ foreach (var element in markup)+ element.ReplaceWith(element.Nodes());+ return markup.Count > 0;+ }++ private static bool IsKoboSpan(XElement element) =>+ element.Name.LocalName == "span" && ((string?)element.Attribute("class") ?? "").Split(' ').Contains(SpanClass);++ private static bool IsWrapper(XElement element) =>+ element.Name.LocalName == "div" && (string?)element.Attribute("id") is ColumnsId or InnerId;+}diff --git a/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs b/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.csindex ee586cc7..e816bf57 100644--- a/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs+++ b/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs@@ -37,6 +37,7 @@ internal static class DocumentReaders["csv"] = (path, _) => SheetDocument.Build(CsvFormat.Read(path)),["tsv"] = (path, _) => SheetDocument.Build(SpreadsheetConverter.Read(path, "tsv")),["xls"] = (path, _) => SheetDocument.Build(SpreadsheetConverter.Read(path, "xls")),+ ["xlt"] = (path, _) => SheetDocument.Build(SpreadsheetConverter.Read(path, "xlt")),["ods"] = (path, _) => SheetDocument.Build(SpreadsheetConverter.Read(path, "ods")),["pptx"] = PptxReader.Read,["pptm"] = PptxReader.Read,@@ -47,6 +48,7 @@ internal static class DocumentReaders["hwpx"] = HwpxReader.Read,["html"] = HtmlReader.Read,["epub"] = EpubReader.Read,+ ["kepub"] = EpubReader.Read, // a Kobo EPUB: its koboSpan markup is plain spans to the HTML reader["mobi"] = MobiReader.Read,["azw3"] = MobiReader.Read,["azw"] = MobiReader.Read,@@ -67,6 +69,15 @@ internal static class DocumentReaders["html"] = "html",["rst"] = "rst",["tex"] = "latex",+ ["org"] = "org",+ ["adoc"] = "asciidoc",+ ["typ"] = "typst",+ ["mediawiki"] = "mediawiki",+ ["dbk"] = "docbook",+ ["ipynb"] = "ipynb",+ ["textile"] = "textile",+ ["man"] = "man",+ ["opml"] = "opml",};/// <summary>Formats read without any optional engine.</summary>diff --git a/src/Filee.Engines/Office/LibreOfficeConverter.cs b/src/Filee.Engines/Office/LibreOfficeConverter.csindex 88fe61e5..57005fa8 100644--- a/src/Filee.Engines/Office/LibreOfficeConverter.cs+++ b/src/Filee.Engines/Office/LibreOfficeConverter.cs@@ -1,6 +1,8 @@// Office documents via LibreOffice in headless mode (MPL-2.0): the optional fallback for formats the built-in engines// don't handle (DOC, XLS, PPT, OpenDocument, ...) and the only reader of rarer ones: Works / WPS, WordPerfect, Lotus-// Word Pro, AbiWord, Apple Pages / Numbers / Keynote, StarOffice, WPS Office, Publisher, CorelDRAW, Visio, CGM.+// Word Pro, AbiWord, Apple Pages / Numbers / Keynote, StarOffice, WPS Office, ClarisWorks / AppleWorks, MacWrite, T602,+// Pocket Word, flat OpenDocument, Publisher, CorelDRAW, Visio, CGM. It also writes the OpenDocument templates, FODT,+// XLT and EMF / WMF, and turns SVG into EMF / WMF / ODG and a PDF page into SVG.// Uses a selected installation, Filee's downloaded copy, or the system installation.//// Gotchas handled here:@@ -16,6 +18,8 @@using Filee.Core.Conversion;using Filee.Core.Formats;using Filee.Engines.Infrastructure;+using PdfSharp.Pdf;+using PdfSharp.Pdf.IO;namespace Filee.Engines.Office;@@ -28,21 +32,32 @@ public sealed class LibreOfficeConverter : IConverter/// <summary>Usual time of one conversion with a prepared profile (drives the progress estimate).</summary>private static readonly TimeSpan TypicalDuration = TimeSpan.FromSeconds(4);- private static readonly string[] Writer = ["docx", "doc", "odt", "rtf"];- private static readonly string[] Calc = ["xlsx", "xls", "ods", "csv"];- private static readonly string[] Impress = ["pptx", "ppt", "odp"];+ // Read and written: FODT (flat XML) and the OpenDocument templates (OTT, OTS, OTP), XLT (Excel 97 template).+ private static readonly string[] Writer = ["docx", "doc", "odt", "rtf", "fodt", "ott"];+ private static readonly string[] Calc = ["xlsx", "xls", "ods", "csv", "xlt", "ots"];+ private static readonly string[] Impress = ["pptx", "ppt", "odp", "otp"];// Formats LibreOffice only reads, by the application that opens them (checked against the filter registry of- // LibreOffice 26.2: the DocumentService of each type's preferred import filter).- private static readonly string[] WriterImport = ["dot", "wps", "wpd", "lwp", "abw", "pages", "sdw"];- private static readonly string[] CalcImport = ["et", "numbers", "sdc"];+ // LibreOffice 26.2: the DocumentService of each type's preferred import filter). ClarisWorks / AppleWorks files can+ // also be spreadsheets or drawings; they are taken as word processor files, the common case.+ private static readonly string[] WriterImport = ["dot", "wps", "wpd", "lwp", "abw", "pages", "sdw", "cwk", "mcw", "602", "psw"];+ private static readonly string[] CalcImport = ["et", "numbers", "sdc", "fods"];/// <summary>"sda" also covers .sdd: StarDraw files (.sda) open in Draw, StarImpress files (.sdd) in Impress.</summary>- private static readonly string[] ImpressImport = ["key", "dps", "sda"];+ private static readonly string[] ImpressImport = ["key", "dps", "sda", "fodp"];- /// <summary>CGM opens in Impress but is a drawing: exported like one (PDF, ODG, SVG, PNG).</summary>+ /// <summary>CGM opens in Impress but is a drawing: exported like one (PDF, ODG, SVG, PNG, EMF, WMF).</summary>private static readonly string[] ImpressGraphics = ["cgm"];- private static readonly string[] Draw = ["pub", "cdr", "vsd", "odg", "emf", "wmf"];+ private static readonly string[] Draw = ["pub", "cdr", "vsd", "odg", "fodg", "emf", "wmf"];++ /// <summary>What a drawing is exported as. SVG, PNG, EMF and WMF hold the first page.</summary>+ private static readonly string[] DrawTargets = ["pdf", "odg", "svg", "png", "emf", "wmf"];++ /// <summary>+ /// Opened in Draw although another engine reads them better: SVG (only → EMF / WMF / ODG; the vector engine draws it+ /// to PDF and images) and PDF (only → SVG / ODG; one page for SVG, see <see cref="FirstPage"/>).+ /// </summary>+ private static readonly string[] DrawOnlyFor = ["svg", "pdf"];private readonly EngineEnvironment _env;@@ -89,9 +104,10 @@ public sealed class LibreOfficeConverter : IConverterDirectory.CreateDirectory(outDir);progress?.Report(0.1);+ var input = step.From == "pdf" && step.To == "svg" ? FirstPage(step) : step.InputPath;ProcessResult result;using (ProgressEstimate.Start(progress, TypicalDuration))- result = await RunAsync(soffice, slot, FilterFor(step.From, step.To, step.Preset.Document.PdfA, FormatRegistry.ExtensionOf(step.InputPath)), outDir, step.InputPath, cancellationToken);+ result = await RunAsync(soffice, slot, FilterFor(step.From, step.To, step.Preset.Document.PdfA, FormatRegistry.ExtensionOf(step.InputPath)), outDir, input, cancellationToken);var produced = Directory.EnumerateFiles(outDir).FirstOrDefault(f => new FileInfo(f).Length > 0);if (produced is null)throw new InvalidOperationException(@@ -110,6 +126,25 @@ public sealed class LibreOfficeConverter : IConverter}}+ /// <summary>+ /// The first page of the preset's page range as a PDF of its own: Draw's SVG export writes every page of a PDF on+ /// top of each other, so it gets one page (like the other drawings, whose SVG holds the first page).+ /// </summary>+ private static string FirstPage(ConversionStep step)+ {+ using var source = PdfReader.Open(step.InputPath, PdfDocumentOpenMode.Import);+ var pages = PageRange.Parse(step.Preset.Pdf.PageRange, source.PageCount);+ if (pages.Count == 0)+ throw new InvalidOperationException("The PDF has no pages in the selected range.");+ using var single = new PdfDocument();+ single.AddPage(source.Pages[pages[0]]);+ var folder = Path.Combine(step.WorkDirectory, "lo-page-" + Guid.NewGuid().ToString("N")[..8]);+ Directory.CreateDirectory(folder);+ var path = Path.Combine(folder, FormatRegistry.NameWithoutExtension(step.InputPath) + ".pdf");+ single.Save(path);+ return path;+ }+/// <summary>/// Prepares the worker profiles that were never used, by converting a tiny file with each of them, so the user's/// first conversion doesn't pay for LibreOffice's first start. Quick no-op when LibreOffice is missing or the@@ -211,21 +246,28 @@ public sealed class LibreOfficeConverter : IConverter"docx" => "docx:MS Word 2007 XML","doc" => "doc:MS Word 97","odt" => "odt",+ "fodt" => "fodt:OpenDocument Text Flat XML",+ "ott" => "ott:writer8_template","rtf" => "rtf:Rich Text Format","txt" => "txt:Text (encoded):UTF8","html" when family == "calc" => "html:HTML (StarCalc)","html" => "html:HTML (StarWriter)","xlsx" => "xlsx:Calc MS Excel 2007 XML","xls" => "xls:MS Excel 97",+ "xlt" => "xlt:MS Excel 97 Vorlage/Template","ods" => "ods",+ "ots" => "ots:calc8_template","csv" => "csv:Text - txt - csv (StarCalc):44,34,76","pptx" => "pptx:Impress MS PowerPoint 2007 XML","ppt" => "ppt:MS PowerPoint 97","odp" => "odp",+ "otp" => "otp:impress8_template","odg" when family == "impress" => "odg:impress8_draw","odg" => "odg:draw8","svg" => $"svg:{family}_svg_Export","png" => $"png:{family}_png_Export",+ "emf" => $"emf:{family}_emf_Export",+ "wmf" => $"wmf:{family}_wmf_Export",_ => to,};}@@ -239,7 +281,7 @@ public sealed class LibreOfficeConverter : IConverterreturn "calc";if (Impress.Contains(from) || ImpressImport.Contains(from) || ImpressGraphics.Contains(from))return "impress";- return Draw.Contains(from) ? "draw" : "writer";+ return Draw.Contains(from) || DrawOnlyFor.Contains(from) ? "draw" : "writer";}/// <param name="hwp">H2Orestart is installed (HWP / HWPX import).</param>@@ -280,7 +322,9 @@ public sealed class LibreOfficeConverter : IConverterAdd(WriterImport, [.. Writer, "pdf", "txt", "html"], Fallback);Add(CalcImport, [.. Calc, "pdf", "html"], Fallback);Add(ImpressImport, [.. Impress, "pdf"], Fallback);- Add([.. ImpressGraphics, .. Draw], ["pdf", "odg", "svg", "png"], Fallback);+ Add([.. ImpressGraphics, .. Draw], DrawTargets, Fallback);+ Add(["svg"], ["odg", "emf", "wmf"], Fallback);+ Add(["pdf"], ["svg", "odg"], Fallback);if (hwp){Add(["hwp", "hwpx"], ["docx", "odt", "rtf"], Fallback + 6);diff --git a/src/Filee.Engines/Office/PandocConverter.cs b/src/Filee.Engines/Office/PandocConverter.csindex 61c8cf64..8dac1fee 100644--- a/src/Filee.Engines/Office/PandocConverter.cs+++ b/src/Filee.Engines/Office/PandocConverter.cs@@ -1,13 +1,16 @@// General document conversions with Pandoc (GPL-2.0-or-later, bundled as a separate program in engines/pandoc).-// Adds Markdown ↔ DOCX / ODT / RTF, HTML ↔ DOCX / ODT, and reStructuredText and LaTeX ↔ Markdown / HTML / DOCX / ODT-// (and → RTF, EPUB, TXT); Markdown → HTML / TXT / HWPX / DOCX is built in (MarkdownConverter, the HWPX and DOCX writers).+// Adds Markdown ↔ DOCX / ODT / RTF, HTML ↔ DOCX / ODT, the markup languages (reStructuredText, LaTeX, Org, AsciiDoc,+// Typst, MediaWiki, DocBook, Jupyter notebooks, Textile, man pages, OPML) ↔ Markdown / HTML / DOCX / ODT and each+// other (and → RTF, EPUB, TXT), and Markdown and the lightweight markups → PPTX slides. Markdown → HTML / TXT / HWPX /+// DOCX is built in (MarkdownConverter, the HWPX and DOCX writers).using Filee.Core.Conversion;+using Filee.Core.Formats;using Filee.Engines.Infrastructure;namespace Filee.Engines.Office;-/// <summary>Markdown, HTML, DOCX, ODT, RTF, reStructuredText and LaTeX conversions through Pandoc.</summary>+/// <summary>Markdown, HTML, DOCX, ODT, RTF and markup language conversions through Pandoc.</summary>public sealed class PandocConverter : IConverter{private static readonly TimeSpan Timeout = TimeSpan.FromMinutes(2);@@ -21,6 +24,15 @@ public sealed class PandocConverter : IConverter["rtf"] = "rtf",["rst"] = "rst",["tex"] = "latex",+ ["org"] = "org",+ ["adoc"] = "asciidoc",+ ["typ"] = "typst",+ ["mediawiki"] = "mediawiki",+ ["dbk"] = "docbook",+ ["ipynb"] = "ipynb",+ ["textile"] = "textile",+ ["man"] = "man",+ ["opml"] = "opml",};private static readonly Dictionary<string, string> Writers = new()@@ -34,10 +46,35 @@ public sealed class PandocConverter : IConverter["rst"] = "rst",["tex"] = "latex",["epub"] = "epub",+ ["org"] = "org",+ ["adoc"] = "asciidoc",+ ["typ"] = "typst",+ ["mediawiki"] = "mediawiki",+ ["dbk"] = "docbook5",+ ["ipynb"] = "ipynb",+ ["textile"] = "textile",+ ["man"] = "man",+ ["opml"] = "opml",+ ["pptx"] = "pptx",};- /// <summary>reStructuredText and LaTeX: what Pandoc reads and writes well (no PDF, which would need a TeX engine).</summary>- private static readonly string[] Markup = ["rst", "tex"];+ /// <summary>+ /// Markup languages Pandoc reads and writes well: to and from Markdown, HTML, DOCX and ODT, and into each other.+ /// No PDF, which would need a TeX or Typst engine (PDF comes from the HWPX writer and rhwp instead).+ /// </summary>+ internal static readonly string[] Markup = ["rst", "tex", "org", "adoc", "typ", "mediawiki", "dbk", "ipynb", "textile", "man", "opml"];++ /// <summary>Sources of Pandoc's PowerPoint writer (a slide per heading): Markdown and the lightweight markups.</summary>+ internal static readonly string[] Slides = ["md", "rst", "org", "adoc", "typ", "mediawiki", "textile", "ipynb"];++ /// <summary>Cost of the slide edges, see <see cref="Edges"/>.</summary>+ private const int SlidesCost = 20;++ /// <summary>Targets that are complete documents only with <c>--standalone</c> (root element, header, preamble).</summary>+ private static readonly string[] Standalone = ["html", "tex", "dbk", "man", "opml", "typ"];++ /// <summary>Text targets whose pictures (from DOCX, ODT, EPUB, ...) are extracted into a folder next to them.</summary>+ private static readonly string[] ExtractsMedia = ["md", "html", "rst", "tex", "org", "adoc", "typ", "mediawiki", "textile", "dbk"];private string? _pandoc;@@ -53,14 +90,18 @@ public sealed class PandocConverter : IConverter// Overlaps with LibreOffice (the fallback engine, which costs more)... new[] { "docx", "odt" }.Select(to => new ConversionEdge("html", to, 14)),.. new[] { "docx", "odt" }.Select(from => new ConversionEdge(from, "html", 14)),- // reStructuredText and LaTeX in / out: only Pandoc does this.+ // Markup languages in / out: only Pandoc does this. Writing one costs a little more than writing Markdown, so a+ // route with a Pandoc step in the middle (HTML → ? → RTF) goes through Markdown, not through Org or Typst... from markup in Markup- from to in new[] { "md", "html", "docx", "odt", "rtf", "epub", "txt", "rst", "tex" }- where to != markup+ from to in new[] { "md", "html", "docx", "odt", "rtf", "epub", "txt" }select new ConversionEdge(markup, to),.. from markup in Markup- from source in new[] { "md", "html", "docx", "odt" }- select new ConversionEdge(source, markup),+ from source in new[] { "md", "html", "docx", "odt" }.Concat(Markup)+ where source != markup+ select new ConversionEdge(source, markup, 11),+ // Slides from headings: nothing else writes PPTX from text. Expensive, so text → PDF never takes the shortcut+ // through slides and LibreOffice's cheap PPTX → PDF (Markdown → PPTX → PDF would beat Markdown → HWPX → PDF).+ .. Slides.Select(from => new ConversionEdge(from, "pptx", SlidesCost)),];public EngineStatus GetStatus()@@ -72,15 +113,15 @@ public sealed class PandocConverter : IConverterpublic async Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken){var pandoc = _pandoc ?? Locate() ?? throw new InvalidOperationException("Pandoc was not found.");- var output = step.Output.Allocate(step.To);+ var output = step.Output.Allocate(FormatRegistry.Get(step.To).PrimaryExtension);if (output is null)return [];progress?.Report(0.1);List<string> args = [step.InputPath, "-f", Readers[step.From], "-t", Writers[step.To], "-o", output];- if (step.To is "html" or "tex")+ if (Standalone.Contains(step.To))args.Add("--standalone");- if (step.To is "md" or "html" or "rst" or "tex")+ if (ExtractsMedia.Contains(step.To))args.Add("--extract-media=" + Path.Combine(Path.GetDirectoryName(output)!, Path.GetFileNameWithoutExtension(output) + "_files"));ProcessResult result;diff --git a/src/Filee.Engines/Office/SpreadsheetConverter.cs b/src/Filee.Engines/Office/SpreadsheetConverter.csindex 7b0e0426..411c2957 100644--- a/src/Filee.Engines/Office/SpreadsheetConverter.cs+++ b/src/Filee.Engines/Office/SpreadsheetConverter.cs@@ -12,7 +12,7 @@ namespace Filee.Engines.Office;/// <summary>Converts between spreadsheet formats in-process.</summary>public sealed class SpreadsheetConverter : IConverter{- private static readonly string[] Sources = ["xlsx", "xlsm", "xltx", "xls", "ods", "csv", "tsv"];+ private static readonly string[] Sources = ["xlsx", "xlsm", "xltx", "xls", "xlt", "ods", "csv", "tsv"];private static readonly string[] Targets = ["xlsx", "ods", "csv", "tsv"];public string Id => "spreadsheet";@@ -71,7 +71,7 @@ public sealed class SpreadsheetConverter : IConverter/// <summary>Reads a spreadsheet of a format id this engine accepts.</summary>internal static Workbook Read(string path, string format) => format switch{- "xls" => XlsReader.Read(path),+ "xls" or "xlt" => XlsReader.Read(path),"ods" => OdsReader.Read(path),"csv" => CsvFormat.Read(path),"tsv" => CsvFormat.ReadTsv(path),diff --git a/tests/Filee.Core.Tests/ProfileSelectorTests.cs b/tests/Filee.Core.Tests/ProfileSelectorTests.csindex 2c852bad..5727aa1b 100644--- a/tests/Filee.Core.Tests/ProfileSelectorTests.cs+++ b/tests/Filee.Core.Tests/ProfileSelectorTests.cs@@ -26,6 +26,10 @@ public class ProfileSelectorTests[InlineData("archives", "a.tar.gz", "b.zip")][InlineData("video", @"C:\clips\a.MP4", @"C:\clips\b.mkv")][InlineData("text", "notes.md", "readme.txt")]+ [InlineData("text", "todo.org", "paper.typ", "guide.adoc")]+ [InlineData("ebooks", "novel.kepub.epub", "novel.epub")]+ [InlineData("office", "letter.fodt", "memo.602")]+ [InlineData("spreadsheets", "budget.xlt", "flat.fods")]public void Built_in_profiles_take_their_files(string expected, params string[] files) =>Assert.Equal(expected, Pick(_builtIn, files));diff --git a/tests/Filee.Core.Tests/UserDataStoreTests.cs b/tests/Filee.Core.Tests/UserDataStoreTests.csindex cf18bdab..36bda9f4 100644--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs@@ -210,6 +210,39 @@ public class UserDataStoreTestsAssert.False(SettingsMigrations.ApplyToLibrary(9, presets, profiles)); // once only}+ [Fact]+ public void Version_10_libraries_get_kepub_and_the_new_document_extensions()+ {+ // As written by 1.11.x: no KEPUB preset, and the donuts without the formats added in schema 11.+ string[] added = ["org", "adoc", "typ", "mediawiki", "wiki", "dbk", "ipynb", "fodt", "ott", "cwk", "602", "ots", "fods", "otp", "fodp", "fodg", "kepub.epub"];+ var presets = BuiltInData.CreatePresets();+ presets.RemoveAll(p => p.Id == "to-kepub");+ var profiles = BuiltInData.CreateProfiles();+ foreach (var profile in profiles)+ {+ profile.PresetIds.Remove("to-kepub");+ profile.Extensions.RemoveAll(added.Contains);+ }+ // A donut of the user already handles Org files.+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["org"] });++ Assert.True(SettingsMigrations.ApplyToLibrary(10, presets, profiles));++ Assert.Equal("kepub", presets.Single(p => p.Id == "to-kepub").TargetFormat);+ var ebooks = profiles.Single(p => p.Id == "ebooks");+ Assert.Equal(ebooks.PresetIds.IndexOf("to-mobi") + 1, ebooks.PresetIds.IndexOf("to-kepub"));+ Assert.Contains("kepub.epub", ebooks.Extensions);+ Assert.Contains("typ", profiles.Single(p => p.Id == "text").Extensions);+ Assert.DoesNotContain("org", profiles.Single(p => p.Id == "text").Extensions);+ Assert.Contains("fodt", profiles.Single(p => p.Id == "office").Extensions);+ Assert.Contains("fods", profiles.Single(p => p.Id == "spreadsheets").Extensions);+ Assert.Contains("otp", profiles.Single(p => p.Id == "presentations").Extensions);+ Assert.Contains("fodg", profiles.Single(p => p.Id == "vector").Extensions);+ foreach (var expected in BuiltInData.CreateProfiles())+ Assert.Equal(expected.PresetIds, profiles.Single(p => p.Id == expected.Id).PresetIds);+ Assert.False(SettingsMigrations.ApplyToLibrary(10, presets, profiles)); // once only+ }+[Fact]public void Catalog_migration_ignores_extensions_checked_on_mixed_profiles(){diff --git a/tests/Filee.Engines.Tests/KepubTests.cs b/tests/Filee.Engines.Tests/KepubTests.csnew file mode 100644index 00000000..257b445d--- /dev/null+++ b/tests/Filee.Engines.Tests/KepubTests.cs@@ -0,0 +1,157 @@+// KEPUB (Kobo) built in: EPUB → KEPUB adds Kobo's sentence spans to the spine's chapters and copies everything else,+// KEPUB → EPUB removes them, and other formats reach KEPUB through EPUB. Inputs come from EbookBuilders.++using System.IO.Compression;+using System.Xml.Linq;+using Filee.Core.Conversion;+using Filee.Core.Formats;+using Filee.Core.Presets;+using Filee.Engines.Ebooks;++namespace Filee.Engines.Tests;++public class KepubTests(EngineFixture fx) : IClassFixture<EngineFixture>+{+ private static readonly XNamespace Xhtml = "http://www.w3.org/1999/xhtml";++ private async Task<string> ConvertAsync(string input, string target)+ {+ var job = await fx.ConvertAsync([input], new Preset { TargetFormat = target });+ Assert.True(job.State == JobState.Completed, string.Join("; ", job.Files.Select(f => $"{f.ErrorKey} {f.ErrorDetail}")));+ return job.Outputs.Single();+ }++ private static XDocument Chapter(ZipArchive zip, string name)+ {+ using var stream = zip.GetEntry(name)!.Open();+ return XDocument.Load(stream, LoadOptions.PreserveWhitespace);+ }++ private static List<XElement> Spans(XDocument document) =>+ document.Descendants(Xhtml + "span").Where(s => (string?)s.Attribute("class") == "koboSpan").ToList();++ [Fact]+ public void Kepub_is_detected_by_its_double_extension_and_reached_through_epub()+ {+ Assert.Equal("kepub", FormatRegistry.Detect("책.kepub.epub")!.Id);+ Assert.Equal("epub", FormatRegistry.Detect("책.epub")!.Id);+ Assert.Equal("kepub.epub", FormatRegistry.Get("kepub").PrimaryExtension);++ var planner = fx.Catalog.CreatePlanner();+ Assert.Equal("ebook", Assert.Single(planner.Plan("epub", "kepub")!.Steps).Converter.Id);+ Assert.Equal("ebook", Assert.Single(planner.Plan("kepub", "epub")!.Steps).Converter.Id);+ Assert.Equal(["ebook", "ebook"], planner.Plan("md", "kepub")!.Steps.Select(s => s.Converter.Id));+ Assert.Equal(["ebook", "ebook"], planner.Plan("mobi", "kepub")!.Steps.Select(s => s.Converter.Id));+ Assert.Equal("ebook", Assert.Single(planner.Plan("kepub", "txt")!.Steps).Converter.Id);+ }++ [Fact]+ public async Task Epub_becomes_kepub_with_a_span_per_sentence_and_the_rest_unchanged()+ {+ var epub = EbookBuilders.Epub(fx.NewFolder());+ var kepub = await ConvertAsync(epub, "kepub");++ Assert.EndsWith(".kepub.epub", kepub);+ using var source = ZipFile.OpenRead(epub);+ using var zip = ZipFile.OpenRead(kepub);+ Assert.Equal("mimetype", zip.Entries[0].FullName);+ Assert.Equal(zip.Entries[0].Length, zip.Entries[0].CompressedLength); // stored+ Assert.Equal(source.Entries.Select(e => e.FullName).Order(), zip.Entries.Select(e => e.FullName).Order());++ // Not in the spine: copied byte for byte.+ foreach (var name in new[] { "OEBPS/nav.xhtml", "OEBPS/content.opf", "OEBPS/Images/pic.png", "OEBPS/Styles/book.css" })+ {+ using var a = new MemoryStream();+ using var b = new MemoryStream();+ using (var s = source.GetEntry(name)!.Open()) s.CopyTo(a);+ using (var s = zip.GetEntry(name)!.Open()) s.CopyTo(b);+ Assert.Equal(a.ToArray(), b.ToArray());+ }++ var chapter = Chapter(zip, "OEBPS/Text/ch1.xhtml");+ var body = chapter.Root!.Element(Xhtml + "body")!;+ var columns = Assert.Single(body.Elements());+ Assert.Equal("book-columns", (string?)columns.Attribute("id"));+ Assert.Equal("book-inner", (string?)Assert.Single(columns.Elements()).Attribute("id"));++ var spans = Spans(chapter);+ Assert.Equal(spans.Count, spans.Select(s => (string?)s.Attribute("id")).Distinct().Count());+ Assert.Equal("kobo.1.1", (string?)spans[0].Attribute("id"));+ Assert.Equal("첫 번째 장", spans[0].Value);+ // The second paragraph: "밤하늘에 " "별" "이 " "반짝" "였다. " "크게" "외쳤다." (the space before it stays outside)+ // keep their inline elements.+ var second = spans.Where(s => ((string)s.Attribute("id")!).StartsWith("kobo.2.", StringComparison.Ordinal)).ToList();+ Assert.Equal(["밤하늘에 ", "별", "이 ", "반짝", "였다. ", "크게", "외쳤다."], second.Select(s => s.Value));+ Assert.Equal("밤하늘에 별이 반짝였다. 크게 외쳤다.", second[0].Parent!.Value);+ Assert.Contains(second, s => s.Parent!.Name == Xhtml + "b" && s.Value == "별");+ // The text reads the same as before.+ var before = Chapter(source, "OEBPS/Text/ch1.xhtml").Root!.Element(Xhtml + "body")!.Value;+ Assert.Equal(before, body.Value);++ // Pictures get a span of their own.+ var pictures = Chapter(zip, "OEBPS/Text/ch2.xhtml").Descendants(Xhtml + "img").ToList();+ Assert.All(pictures, img => Assert.Equal("koboSpan", (string?)img.Parent!.Attribute("class")));+ // A file name with a space (escaped in the package document) is found.+ Assert.NotEmpty(Spans(Chapter(zip, "OEBPS/Text/ch 3.xhtml")));+ Assert.Empty(Spans(Chapter(zip, "OEBPS/nav.xhtml")));+ }++ [Fact]+ public async Task Kepub_reads_back_and_turns_into_a_plain_epub()+ {+ var kepub = await ConvertAsync(EbookBuilders.Epub(fx.NewFolder()), "kepub");++ var text = await File.ReadAllTextAsync(await ConvertAsync(kepub, "txt"), TestContext.Current.CancellationToken);+ Assert.Contains("밤하늘에 별이 반짝였다.", text);++ var epub = await ConvertAsync(kepub, "epub");+ Assert.Equal("epub", FormatRegistry.Detect(epub)!.Id);+ using var zip = ZipFile.OpenRead(epub);+ foreach (var name in new[] { "OEBPS/Text/ch1.xhtml", "OEBPS/Text/ch2.xhtml", "OEBPS/Text/ch 3.xhtml" })+ {+ var chapter = Chapter(zip, name);+ Assert.Empty(Spans(chapter));+ Assert.DoesNotContain(chapter.Descendants(), e => (string?)e.Attribute("id") is "book-columns" or "book-inner");+ }+ Assert.Contains("<b>별</b>", new StreamReader(zip.GetEntry("OEBPS/Text/ch1.xhtml")!.Open()).ReadToEnd());+ }++ [Fact]+ public async Task Markdown_becomes_kepub_through_epub()+ {+ var md = Path.Combine(fx.NewFolder(), "notes.md");+ await File.WriteAllTextAsync(md, "# Notes\n\nFirst sentence. Second sentence!\n\nAnother paragraph.\n", TestContext.Current.CancellationToken);++ var kepub = await ConvertAsync(md, "kepub");++ Assert.Equal("notes.kepub.epub", Path.GetFileName(kepub));+ using var zip = ZipFile.OpenRead(kepub);+ var spans = Kepub.ContentDocuments(zip).SelectMany(name => Spans(Chapter(zip, name))).Select(s => s.Value).ToList();+ Assert.Contains("First sentence. ", spans);+ Assert.Contains("Second sentence!", spans);+ }++ [Fact]+ public void Html_entities_and_a_second_pass_are_handled()+ {+ var document = Kepub.Load("<?xml version=\"1.0\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><body><p>A b & c… Done.</p><svg xmlns=\"http://www.w3.org/2000/svg\"><text>Skip me.</text></svg></body></html>"u8.ToArray());++ Assert.NotNull(document);+ Assert.NotNull(document.DocumentType);+ Assert.True(Kepub.AddSpans(document));+ Assert.Equal(["A b & c… ", "Done."], Spans(document).Select(s => s.Value));+ Assert.False(Kepub.AddSpans(document)); // already a KEPUB+ Assert.True(Kepub.RemoveSpans(document));+ Assert.Empty(Spans(document));+ Assert.Null(Kepub.Load("<html><p>not XML"u8.ToArray()));+ }++ [Theory]+ [InlineData("One. Two? Three!", new[] { "One. ", "Two? ", "Three!" })]+ [InlineData("Pi is 3.14 today.", new[] { "Pi is 3.14 today." })]+ [InlineData("He said \"Stop.\" Then left.", new[] { "He said \"Stop.\" ", "Then left." })]+ [InlineData("你好。再见!", new[] { "你好。", "再见!" })]+ [InlineData("별이 반짝였다. 크게 외쳤다.", new[] { "별이 반짝였다. ", "크게 외쳤다." })]+ public void Sentences_end_at_punctuation(string text, string[] expected) =>+ Assert.Equal(expected, Kepub.Sentences(text));+}diff --git a/tests/Filee.Engines.Tests/LibreOfficeFormatTests.cs b/tests/Filee.Engines.Tests/LibreOfficeFormatTests.csindex 43ec1c31..9bbb3b8b 100644--- a/tests/Filee.Engines.Tests/LibreOfficeFormatTests.cs+++ b/tests/Filee.Engines.Tests/LibreOfficeFormatTests.cs@@ -39,20 +39,35 @@ public class LibreOfficeFormatTests(EngineFixture fx) : IClassFixture<EngineFixt[InlineData("cgm", "svg", null, "svg:impress_svg_Export")][InlineData("emf", "pdf", null, "pdf:draw_pdf_Export")][InlineData("wmf", "png", null, "png:draw_png_Export")]+ [InlineData("cwk", "docx", null, "docx:MS Word 2007 XML")]+ [InlineData("602", "pdf", null, "pdf:writer_pdf_Export")]+ [InlineData("psw", "odt", null, "odt")]+ [InlineData("fods", "xlsx", null, "xlsx:Calc MS Excel 2007 XML")]+ [InlineData("fodp", "pdf", null, "pdf:impress_pdf_Export")]+ [InlineData("fodg", "emf", null, "emf:draw_emf_Export")]+ [InlineData("cgm", "wmf", null, "wmf:impress_wmf_Export")]+ [InlineData("svg", "wmf", null, "wmf:draw_wmf_Export")]+ [InlineData("pdf", "svg", null, "svg:draw_svg_Export")]+ [InlineData("pdf", "odg", null, "odg:draw8")]+ [InlineData("docx", "fodt", null, "fodt:OpenDocument Text Flat XML")]+ [InlineData("odt", "ott", null, "ott:writer8_template")]+ [InlineData("ods", "ots", null, "ots:calc8_template")]+ [InlineData("xlsx", "xlt", null, "xlt:MS Excel 97 Vorlage/Template")]+ [InlineData("pptx", "otp", null, "otp:impress8_template")]public void Filters_follow_the_application_that_opens_the_file(string from, string to, string? extension, string expected) =>Assert.Equal(expected, LibreOfficeConverter.FilterFor(from, to, pdfA: false, extension));[Fact]public void Every_edge_has_a_filter_of_its_application(){- string[] draw = ["pub", "cdr", "vsd", "odg", "emf", "wmf"];- string[] impress = ["pptx", "ppt", "odp", "key", "dps", "sda", "cgm"];- string[] calc = ["xlsx", "xls", "ods", "csv", "et", "numbers", "sdc"];+ string[] draw = ["pub", "cdr", "vsd", "odg", "fodg", "emf", "wmf", "svg", "pdf"];+ string[] impress = ["pptx", "ppt", "odp", "otp", "fodp", "key", "dps", "sda", "cgm"];+ string[] calc = ["xlsx", "xls", "xlt", "ods", "ots", "fods", "csv", "et", "numbers", "sdc"];foreach (var edge in LibreOffice.Edges){var filter = LibreOfficeConverter.FilterFor(edge.From, edge.To, pdfA: false);var application = draw.Contains(edge.From) ? "draw" : impress.Contains(edge.From) ? "impress" : calc.Contains(edge.From) ? "calc" : "writer";- if (edge.To is "pdf" or "svg" or "png")+ if (edge.To is "pdf" or "svg" or "png" or "emf" or "wmf")Assert.Equal($"{edge.To}:{application}_{edge.To}_Export", filter);else if (edge.To is not ("odt" or "ods" or "odp"))Assert.Contains(':', filter);@@ -60,8 +75,108 @@ public class LibreOfficeFormatTests(EngineFixture fx) : IClassFixture<EngineFixt// Built-in engines stay first: LibreOffice's edges cost more than a normal direct conversion, except// presentations → PDF, which it lays out like PowerPoint (Settings → Engines, on by default).Assert.All(LibreOffice.Edges.Where(e => !(impress.Contains(e.From) && e.To == "pdf")), e => Assert.True(e.Cost >= 25));- foreach (var from in new[] { "dot", "wps", "wpd", "lwp", "abw", "pages", "sdw", "et", "numbers", "sdc", "key", "dps", "sda", "pub", "cdr", "cgm", "vsd", "odg" })+ foreach (var from in new[] { "dot", "wps", "wpd", "lwp", "abw", "pages", "sdw", "cwk", "mcw", "602", "psw", "fodt", "ott", "et", "numbers", "sdc", "fods", "ots", "xlt", "key", "dps", "sda", "fodp", "otp", "pub", "cdr", "cgm", "vsd", "odg", "fodg" })Assert.Contains(LibreOffice.Edges, e => e.From == from && e.To == "pdf");+ // Read-only formats are never targets.+ Assert.All(LibreOffice.Edges, e => Assert.True(Core.Formats.FormatRegistry.Get(e.To).Writable, e.To));+ }++ [Fact]+ public void Svg_and_pdf_open_in_draw_only_where_nothing_else_does_better()+ {+ var planner = fx.Catalog.CreatePlanner(["libreoffice", "ghostscript"]);++ // The vector engine keeps SVG → PDF and images.+ Assert.Equal("vector", Assert.Single(planner.Plan("svg", "pdf")!.Steps).Converter.Id);+ Assert.Equal("vector", Assert.Single(planner.Plan("svg", "png")!.Steps).Converter.Id);+ Assert.Equal("pdfium", Assert.Single(planner.Plan("pdf", "png")!.Steps).Converter.Id);+ foreach (var to in new[] { "emf", "wmf", "odg" })+ Assert.Equal("libreoffice", Assert.Single(planner.Plan("svg", to)!.Steps).Converter.Id);+ Assert.Equal("libreoffice", Assert.Single(planner.Plan("pdf", "svg")!.Steps).Converter.Id);+ // EPS goes through Ghostscript's PDF: Draw would only show the EPS preview picture.+ Assert.Equal(["ghostscript", "libreoffice"], planner.Plan("eps", "svg")!.Steps.Select(s => s.Converter.Id));+ Assert.DoesNotContain(LibreOffice.Edges, e => e.From is "eps" or "ps");+ }++ [Fact]+ public async Task Flat_opendocument_and_text_formats_convert()+ {+ SkipUnlessInstalled();+ var folder = fx.NewFolder();+ async Task<string> Write(string name, string text)+ {+ var path = Path.Combine(folder, name);+ await File.WriteAllTextAsync(path, text, TestContext.Current.CancellationToken);+ return path;+ }+ const string Office = "xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\" " ++ "xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\" xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\" " ++ "xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\" office:version=\"1.3\"";+ var fodt = await Write("letter.fodt", $"<?xml version=\"1.0\" encoding=\"UTF-8\"?><office:document {Office} office:mimetype=\"application/vnd.oasis.opendocument.text\"><office:body><office:text><text:p>Hello flat text</text:p></office:text></office:body></office:document>");+ var fods = await Write("sheet.fods", $"<?xml version=\"1.0\" encoding=\"UTF-8\"?><office:document {Office} office:mimetype=\"application/vnd.oasis.opendocument.spreadsheet\"><office:body><office:spreadsheet><table:table table:name=\"Data\"><table:table-row><table:table-cell office:value-type=\"string\"><text:p>Flat cell</text:p></table:table-cell><table:table-cell office:value-type=\"float\" office:value=\"42\"><text:p>42</text:p></table:table-cell></table:table-row></table:table></office:spreadsheet></office:body></office:document>");+ var fodp = await Write("deck.fodp", $"<?xml version=\"1.0\" encoding=\"UTF-8\"?><office:document {Office} office:mimetype=\"application/vnd.oasis.opendocument.presentation\"><office:body><office:presentation><draw:page draw:name=\"p1\"><draw:frame svg:x=\"2cm\" svg:y=\"2cm\" svg:width=\"20cm\" svg:height=\"3cm\"><draw:text-box><text:p>Flat slide</text:p></draw:text-box></draw:frame></draw:page></office:presentation></office:body></office:document>");+ var fodg = await Write("shape.fodg", $"<?xml version=\"1.0\" encoding=\"UTF-8\"?><office:document {Office} office:mimetype=\"application/vnd.oasis.opendocument.graphics\"><office:body><office:drawing><draw:page draw:name=\"p1\"><draw:rect svg:x=\"2cm\" svg:y=\"2cm\" svg:width=\"8cm\" svg:height=\"4cm\"><text:p>Flat drawing</text:p></draw:rect></draw:page></office:drawing></office:body></office:document>");+ // T602: plain text with dot commands, written by the Czech word processor.+ var t602 = await Write("memo.602", "@CT 0\n@LM 1\nHello T602 memo\n");++ Assert.Contains("Hello flat text", DocxText(await ConvertAsync(fodt, "docx")));+ using (var pdf = PdfDocument.Open(await ConvertAsync(t602, "pdf")))+ Assert.Contains("Hello T602 memo", pdf.GetPage(1).Text);+ using (var pdf = PdfDocument.Open(await ConvertAsync(fodp, "pdf")))+ Assert.Contains("Flat slide", pdf.GetPage(1).Text);+ Assert.Contains("Flat drawing", await File.ReadAllTextAsync(await ConvertAsync(fodg, "svg"), TestContext.Current.CancellationToken));++ // Templates and flat XML out: OpenDocument packages with the template media type.+ Assert.Equal("application/vnd.oasis.opendocument.text-template", Mimetype(await ConvertAsync(fodt, "ott")));+ Assert.Equal("application/vnd.oasis.opendocument.spreadsheet-template", Mimetype(await ConvertAsync(fods, "ots")));+ Assert.Equal("application/vnd.oasis.opendocument.presentation-template", Mimetype(await ConvertAsync(fodp, "otp")));+ var flat = await ConvertAsync(await ConvertAsync(fodt, "odt"), "fodt");+ Assert.Contains("Hello flat text", await File.ReadAllTextAsync(flat, TestContext.Current.CancellationToken));+ // An Excel 97 template, read back by the built-in spreadsheet engine.+ var xlt = await ConvertAsync(fods, "xlt");+ Assert.Equal("xlt", Core.Formats.FormatRegistry.Detect(xlt)!.Id);+ Assert.Contains("Flat cell,42", await File.ReadAllTextAsync(await ConvertAsync(xlt, "csv"), TestContext.Current.CancellationToken));+ }++ [Fact]+ public async Task Svg_becomes_emf_wmf_and_odg_and_a_pdf_page_becomes_svg()+ {+ SkipUnlessInstalled();+ var folder = fx.NewFolder();+ var svg = Path.Combine(folder, "badge.svg");+ await File.WriteAllTextAsync(svg, "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" height=\"100\"><rect x=\"10\" y=\"10\" width=\"180\" height=\"80\" fill=\"#3a7\"/><text x=\"20\" y=\"60\" font-size=\"20\">Filee</text></svg>", TestContext.Current.CancellationToken);++ var emf = await File.ReadAllBytesAsync(await ConvertAsync(svg, "emf"), TestContext.Current.CancellationToken);+ Assert.Equal(" EMF"u8.ToArray(), emf[40..44]); // EMR_HEADER signature+ var wmf = await File.ReadAllBytesAsync(await ConvertAsync(svg, "wmf"), TestContext.Current.CancellationToken);+ Assert.True(wmf[..4].SequenceEqual(new byte[] { 0xD7, 0xCD, 0xC6, 0x9A }) || wmf[..2].SequenceEqual(new byte[] { 1, 0 }), "not a WMF");+ Assert.Equal("application/vnd.oasis.opendocument.graphics", Mimetype(await ConvertAsync(svg, "odg")));++ // Draw's SVG export draws every page of a PDF on top of each other: only the first one is converted.+ var fodt = Path.Combine(folder, "pages.fodt");+ await File.WriteAllTextAsync(fodt, """+ <?xml version="1.0" encoding="UTF-8"?>+ <office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">+ <office:automatic-styles><style:style style:name="P1" style:family="paragraph"><style:paragraph-properties fo:break-before="page"/></style:style></office:automatic-styles>+ <office:body><office:text><text:p>Page one</text:p><text:p text:style-name="P1">Page two</text:p></office:text></office:body></office:document>+ """, TestContext.Current.CancellationToken);+ var pdf = await ConvertAsync(fodt, "pdf");+ using (var document = PdfDocument.Open(pdf))+ Assert.Equal(2, document.NumberOfPages);+ var page = await File.ReadAllTextAsync(await ConvertAsync(pdf, "svg"), TestContext.Current.CancellationToken);+ Assert.Contains("Page one", page);+ Assert.DoesNotContain("Page two", page);+ var second = await fx.ConvertAsync([pdf], new Preset { TargetFormat = "svg", Pdf = { PageRange = "2" } });+ Assert.Contains("Page two", await File.ReadAllTextAsync(second.Outputs.Single(), TestContext.Current.CancellationToken));+ }++ private static string DocxText(string docx) =>+ string.Concat(DocxAssert.Paragraphs(DocxAssert.ReadBack(docx).Sections.SelectMany(s => s.Blocks)).Select(DocxAssert.TextOf));++ private static string Mimetype(string package)+ {+ using var zip = ZipFile.OpenRead(package);+ return new StreamReader(zip.GetEntry("mimetype")!.Open()).ReadToEnd();}[Fact]diff --git a/tests/Filee.Engines.Tests/PandocMarkupTests.cs b/tests/Filee.Engines.Tests/PandocMarkupTests.csindex d97dd64e..58d194ef 100644--- a/tests/Filee.Engines.Tests/PandocMarkupTests.cs+++ b/tests/Filee.Engines.Tests/PandocMarkupTests.cs@@ -3,6 +3,7 @@using System.IO.Compression;using Filee.Core.Conversion;+using Filee.Core.Formats;using Filee.Core.Presets;using Filee.Engines.Hwp.Hwpx;using Filee.Engines.Office;@@ -65,6 +66,102 @@ public class PandocMarkupTests(EngineFixture fx) : IClassFixture<EngineFixture>Assert.Equal("hwpx-writer", Assert.Single(planner.Plan("tex", "hwpx")!.Steps).Converter.Id);}+ [Fact]+ public void More_markup_languages_and_slides()+ {+ var planner = fx.Catalog.CreatePlanner(["pandoc", "libreoffice"]);+ foreach (var markup in PandocConverter.Markup)+ {+ Assert.NotNull(FormatRegistry.FindById(markup));+ foreach (var other in new[] { "md", "html", "docx", "odt" })+ {+ Assert.Equal("pandoc", Assert.Single(planner.Plan(other, markup)!.Steps).Converter.Id);+ Assert.NotNull(planner.Plan(markup, other));+ }+ Assert.NotNull(planner.Plan(markup, "epub"));+ }+ Assert.Equal("pandoc", Assert.Single(planner.Plan("org", "adoc")!.Steps).Converter.Id);+ Assert.Equal("pandoc", Assert.Single(planner.Plan("md", "pptx")!.Steps).Converter.Id);+ Assert.Equal("pandoc", Assert.Single(planner.Plan("org", "pptx")!.Steps).Converter.Id);+ // Markdown keeps its built-in routes.+ Assert.Equal("markdown", Assert.Single(planner.Plan("md", "html")!.Steps).Converter.Id);+ Assert.Equal("docx-writer", Assert.Single(planner.Plan("md", "docx")!.Steps).Converter.Id);+ // Extensions that could mean something else are not claimed.+ Assert.Null(FormatRegistry.FindByExtension("xml"));+ Assert.Null(FormatRegistry.FindByExtension("1"));+ Assert.Equal("mediawiki", FormatRegistry.FindByExtension("wiki")!.Id);+ Assert.Equal("adoc", FormatRegistry.FindByExtension("asciidoc")!.Id);++ Assert.SkipUnless(PandocConverter.Locate() is not null, "Pandoc not found (pwsh build/fetch-engines.ps1 -Only pandoc)");+ // Not through slides and LibreOffice's PPTX → PDF.+ Assert.Equal(["hwpx-writer", "rhwp"], planner.Plan("org", "pdf")!.Steps.Select(s => s.Converter.Id));+ Assert.Equal(["hwpx-writer", "rhwp"], planner.Plan("md", "pdf")!.Steps.Select(s => s.Converter.Id));+ Assert.Equal(["hwpx-writer", "rhwp"], planner.Plan("typ", "pdf")!.Steps.Select(s => s.Converter.Id));+ }++ [Fact]+ public async Task Markdown_round_trips_through_every_markup_language()+ {+ SkipUnlessInstalled();+ var markdown = await WriteAsync("notes.md", "# Plan\n\nShip **today** and *test*.\n\n- alpha\n- beta\n\n# Later\n\nMore text.\n");++ foreach (var markup in PandocConverter.Markup.Where(m => m is not ("rst" or "tex")))+ {+ var converted = await ConvertAsync(markdown, markup);+ Assert.Equal(markup, FormatRegistry.Detect(converted)!.Id);+ var back = await File.ReadAllTextAsync(await ConvertAsync(converted, "md"), TestContext.Current.CancellationToken);+ Assert.True(back.Contains("today", StringComparison.Ordinal) && back.Contains("alpha", StringComparison.Ordinal), $"{markup}: {back}");+ }+ }++ [Fact]+ public async Task Org_asciidoc_and_typst_reach_hwpx_and_slides()+ {+ SkipUnlessInstalled();+ var org = await WriteAsync("todo.org", "* Groceries\nBuy *milk* and /bread/.\n* Chores\n- sweep\n- dust\n");+ var adoc = await WriteAsync("guide.adoc", "= Guide\n\n== Install\n\nRun the *installer*.\n\n== Use\n\nOpen the app.\n");+ var typ = await WriteAsync("paper.typ", "= Introduction\nTypst is *fast*.\n\n= Method\nWe measure.\n");++ foreach (var (input, text) in new[] { (org, "milk"), (adoc, "installer"), (typ, "fast") })+ {+ var hwpx = await ConvertAsync(input, "hwpx");+ HwpxAssert.ValidPackage(hwpx);+ Assert.Contains(text, HwpxAssert.Xml(hwpx).Value);++ using var pptx = ZipFile.OpenRead(await ConvertAsync(input, "pptx"));+ Assert.Contains(pptx.Entries, e => e.FullName == "ppt/slides/slide2.xml");+ }+ }++ [Fact]+ public async Task Notebooks_outlines_and_man_pages_are_read()+ {+ SkipUnlessInstalled();+ var notebook = await WriteAsync("analysis.ipynb", """+ {"cells": [+ {"cell_type": "markdown", "metadata": {}, "source": ["# Analysis\n", "Results are *good*."]},+ {"cell_type": "code", "metadata": {}, "execution_count": 1, "outputs": [], "source": ["print(42)"]}+ ],+ "metadata": {"kernelspec": {"name": "python3", "display_name": "Python 3", "language": "python"}},+ "nbformat": 4, "nbformat_minor": 5}+ """);+ var outline = await WriteAsync("ideas.opml", """+ <?xml version="1.0" encoding="UTF-8"?>+ <opml version="2.0"><head><title>Ideas</title></head>+ <body><outline text="First idea"><outline text="Detail one"/></outline><outline text="Second idea"/></body></opml>+ """);+ var man = await WriteAsync("tool.man", ".TH TOOL 1\n.SH NAME\ntool \\- does things\n.SH DESCRIPTION\nThe \\fBtool\\fR command runs.\n");++ var fromNotebook = await File.ReadAllTextAsync(await ConvertAsync(notebook, "md"), TestContext.Current.CancellationToken);+ Assert.Contains("# Analysis", fromNotebook);+ Assert.Contains("print(42)", fromNotebook);+ var fromOutline = await File.ReadAllTextAsync(await ConvertAsync(outline, "html"), TestContext.Current.CancellationToken);+ Assert.Contains("First idea", fromOutline);+ Assert.Contains("Detail one", fromOutline);+ var fromMan = await File.ReadAllTextAsync(await ConvertAsync(man, "txt"), TestContext.Current.CancellationToken);+ Assert.Contains("command runs", fromMan);+ }+[Fact]public async Task Rst_to_docx_markdown_and_hwpx(){