Skip to content

Releases

v0.24.3

Choose a tag to compare

@github-actions github-actions released this 29 Nov 11:17
dcc3e15

Changed

  • (bindings) Fix the SonarQube issues of the JVM's native download

SonarQube Cloud reported four issues on #47 (the download of the JVM's native library from the GitHub release). This fixes all four, without a change in behaviour:

  • java:S3776: Native.load() had a cognitive complexity of 16, above the limit of 15. Loading the library of the release, from the cache or from its download, is now a method of its own, loadFromRelease.
  • java:S1845: the method manifest() was named like the field MANIFEST. It is now releaseManifest().
  • java:S1168: the helper that reads the library out of a native JAR returned null when the JAR lacked it. It now throws the IOException the caller threw.
  • java:S112: a test helper declared throws Exception. It now declares NoSuchAlgorithmException.

v0.24.2

Choose a tag to compare

@github-actions github-actions released this 29 Nov 10:47
bdfdb46

Documentation

  • Improve the SEO of the documentation site

The documentation site now tells search engines and link previews what each page is, so it can be found and shared with a proper title, description and picture.

What changes

  • sitemap.xml and robots.txt, written at the root of the site from the table of contents. (robots.txt is read by crawlers only when the site is on a custom domain; on github.io the sitemap is what counts, and it is submitted in Search Console.)
  • A title and a description for every page. docs/site/seo.toml holds titles with the words people search for ("Convert Word (.docx, .doc) to Markdown, HTML, PDF", "Convert PDF to LaTeX", ...) and descriptions of at most 160 characters. A page without an entry gets its sidebar title and the start of its first paragraph.
  • Canonical addresses, Open Graph and Twitter card tags on every page, with the logo as the picture of link previews (docs/assets/logo-256.png), and schema.org JSON-LD on the home page.
  • noindex on the 404 page.
  • The tag of Google Search Console's ownership check in the head of every page.
  • The kakemono logo as the favicon (it was mdBook's).

The three titles of the design notes were all "Design notes"; they now say what they are about.

How

scripts/build-docs.py applies seo.toml to the pages after mdBook has built them. With a custom domain, change site-url in seo.toml. CLAUDE.md says that a new page needs an entry there. scripts/tests/test_build_docs.py tests the descriptions and the head tags.

v0.24.1

Choose a tag to compare

@github-actions github-actions released this 29 Nov 10:32
8952e8e

Documentation

  • Add a documentation site (mdBook, GitHub Pages)

kakemono now has a documentation site, built with mdBook from the Markdown files already in the repository: a sidebar grouped by task (Getting started, Inputs, Outputs, Libraries and bindings, Reference, Development), search, a light theme by default with a dark one in the theme menu, and a layout that works on a phone.

What changes

  • A guide split by topic. docs/GUIDE.md (913 lines) is now one page per topic in docs/guide/ (installation, usage, each input and output format, editable JSON, chunks, the library, limitations, performance, testing). docs/GUIDE.md stays as the list of those pages, and the links of the README point to the new pages. The text is unchanged apart from the headings and the links.
  • An introduction page (docs/index.md) with the inputs and outputs in tables, the four HTML modes and where to start.
  • scripts/build-docs.py gathers docs/ and ARCHITECTURE.md, CONTRIBUTING.md and CHANGELOG.md, makes every relative link work on the site (a link to a file outside the site becomes its address on GitHub) and runs mdBook. The files themselves are not changed, so their links keep working on GitHub. --check fails on a link to a file that does not exist.
  • .github/workflows/docs.yml builds the site on every change to the pages, and publishes it to the gh-pages branch when the change reaches main. It uses only actions already pinned in the other workflows.
  • The site settings, table of contents and style sheet are in docs/site/. CLAUDE.md describes how to add a page.

To publish the site

After the first merge, turn on Settings → Pages → Deploy from a branch → gh-pages / root. The site is then at https://iamcaominhtien.github.io/kakemono/.

v0.24.0

Choose a tag to compare

@github-actions github-actions released this 29 Nov 10:08
f76aefa

Added

  • (bindings) Download the JVM's native library from the GitHub release, and publish to Maven Central by hand

Maven Central now publishes on its own monthly limits: about 78 MB, 1,167 files and 7 releases for an organization. One release of the Java packages was about 121 MB, almost all of it the 8 native JARs, and this repository released 35 versions in November. Central reported the release-size limit as reached, with 30 days of grace.

The Java packages now fit under those limits, following what other projects with large native binaries do.

Native libraries from the GitHub release

  • Release job. The Maven job of Bindings puts each platform's kakemono-native-<version>-<platform>.jar on the GitHub release of the version. It writes the SHA-256 of each library into the kakemono JAR (natives.properties). A JAR already on the release, from a run started again, is kept, and its library is the one named.
  • Upload to Central. It leaves out kakemono-native (excludeArtifacts) and the SHA-256 and SHA-512 checksum files (checksums=required). Built locally with skipUpload, the bundle is about 414 KB instead of about 120 MB.
  • Loading in Java. Native looks for the library at -Dkakemono.library.path, then on the class path, then in the cache. Otherwise it downloads the JAR of its version from the release, through the JVM's proxy settings. It loads the library only when its SHA-256 is the one the JAR names.
    • -Dkakemono.native.url names a mirror.
    • -Dkakemono.native.download=false turns the download off.
    • The last place it looks is java.library.path.
  • Older versions. Up to 0.22.3 the native JARs stay on Central as kakemono-native.

Maven Central only by hand

The Bindings workflow publishes the Java packages to Central only when it is started by hand with the new input maven:

gh workflow run bindings.yml --ref main -f maven=true

Every release still puts the native JARs on its GitHub release. npm and NuGet are published as before. docs/BINDINGS.md ("Releases") and bindings/jvm/README.md ("Native library") describe both changes.

No new secret is needed: the Maven job's own GITHUB_TOKEN gets contents: write to upload the JARs.

v0.23.0

Choose a tag to compare

@github-actions github-actions released this 29 Nov 09:47
3ac1292

Added

  • PowerPoint presentations (.pptx) as input, with their slides as pages

PowerPoint presentations (.pptx, and .pptm, .ppsx, .ppsm, .potx, .potm) become an input like Word and Excel. Every output works:

  • The flowing outputs (friendly HTML, Markdown, Word, LaTeX, Typst, EPUB, editable JSON, chunks): a section per visible slide, headed by its title; sections as headings above them; bullets as lists at their levels, tables with merged cells, pictures with their descriptions, charts with their data tables, SmartArt as lists, formulas as math; speaker notes after their slide.
  • The pages (-o x.pdf, and hard, hard-95, medium through the PDF pipeline): each visible slide is drawn as PowerPoint draws it.

A new reader src/powerpoint/ turns each slide, through its layout and master, into word::ir, which word/build.rs builds as it does for EPUB. A new src/layout/slides/ draws the pages with the Word layout engine. InputFormat::Pptx is new; InputFormat is #[non_exhaustive], so this is not a breaking change. The editable JSON's format version is unchanged.

The bindings (Node.js, WebAssembly, JVM, .NET, C) read decks too: their format is pptx, and, as for a workbook, the modes that draw the slides do not show edited text.

Reading rules

  • Titles come from the title placeholder. Without one, a large text box near the top of the slide is the title; failing that, the slide is headed "Slide N".
  • The first slide is front matter when it is a title slide. That includes corporate templates that set the title slide in body placeholders.
  • Reading order follows where shapes lie (cut into columns and rows), not the order of the shape tree.
  • Left out:
    • hidden slides;
    • placeholder prompts ("Click to add title");
    • footers, dates and slide numbers;
    • the layout's and master's shapes;
    • banners repeated on many slides;
    • PowerPoint's default title "PowerPoint Presentation";
    • the heading of a deck's only section.
  • The thresholds are PowerPointConfig, re-exported by config.rs.

The pages

What is drawn:

  • backgrounds from the slide, layout or master;
  • outlines with solid, see-through, gradient and picture fills;
  • pictures, cropped and turned;
  • text frames with PowerPoint's line height (1.2 × size), insets, anchoring, autofit, bullets, unwrapped and vertical text;
  • links in the theme colour, and highlights;
  • tables with their table style (PowerPoint's default built in);
  • charts, SmartArt and OLE pictures.

Measured against PowerPoint's own PDFs of the five corpus decks that publish one:

  • 91.6% of PowerPoint's lines break at the same words;
  • all five decks have the same page count.

Fixes to shared code, found on the way

Each is its own commit:

  • fix(metafile): a WMF window with a negative extent is now mapped as GDI maps it. Such clip art was drawn empty.

  • fix(drawing): tint and shade are computed in linear light, as Office does. Table bands and default outlines were too dark; this was checked against known Office colours.

  • fix(layout): characters other fonts lack now fall back to Japanese fonts.

  • feat(drawing): 11 more preset outlines.

  • fix(chart): a plot area placed by hand (c:manualLayout) is drawn where the file puts it. Long category labels are no longer cut.

  • fix(render): a table with no body rows no longer leaves <thead> open. That made the EPUB's XHTML malformed.

  • perf(analysis): the rules that compare a line or a glyph with its neighbours (justified gaps, drop caps, scripts, running heads, page furniture) look only within a band of baselines (common::band), not at the whole page. The output is unchanged: identical, byte for byte, on 502 PDFs (the test papers, the Word and PowerPoint corpora, dense pages).

    Dense page Before After
    20 000 glyphs in a grid, friendly 8.5 s 0.42 s
    the same, hard-95 12 s 0.62 s
    20 000 overlapping glyphs, friendly 60–75 s 2.2 s
    the same, hard-95 72 s 5.2 s
  • fix(pdf) (two commits): a PDF's output no longer depends on how its pages are shared out among threads. Each worker's font registry carried state from page to page (a glyph's font found, or not found, on an earlier page; fonts merged by name in the order the worker met them), and pages go to workers as they free up. So the same PDF could come out differently from one run to the next: about 120 of the 483 PDFs of the Word corpus did (a caption read as a paragraph, a heading lost). Now -j 1 and the default give the same output on all 496 PDFs checked. The body font also takes the lower font number on a tie, not the first in hash order.

Not done

  • .ppt (PowerPoint 97–2003) is not read.
  • Animations, media and effects are not drawn.
  • Curved connectors are drawn straight.
  • Some lines break one word earlier than PowerPoint's: its spaces are a little narrower than the open fonts' spaces.
  • Charts lack trend lines and error bars.
  • The test of the font registry (a_glyphs_font_does_not_depend_on_the_pages_read_before) reads the LIGO paper, which does not show the bug: the PDFs that do cannot be committed.

See docs/POWERPOINT-INPUT.md for details.

v0.22.3

Choose a tag to compare

@github-actions github-actions released this 29 Nov 05:30
e0a0738

Fixed

  • (bindings) Publish the npm packages, and show each publication as a deployment

The first run of the Bindings workflow that published (v0.22.2) put the NuGet package on nuget.org, but both npm jobs failed:

npm error command git --no-replace-objects ls-remote ssh://git@github.com/packages/kakemono-wasm-0.22.2.tgz.git
npm error git@github.com: Permission denied (publickey).

npm publish packages/x.tgz reads packages/x.tgz as the GitHub repository packages/x. The jobs now publish ./packages/x.tgz.

Each publishing job also runs in an environment named after its registry, so a publication shows as a deployment on the repository's page with a link to the published version, as pypi does for the Python package:

Job Environment
npm @kakemono/node npm
npm @kakemono/wasm npm-wasm
Maven Central maven-central
NuGet nuget

The environment is set only when the job publishes. docs/BINDINGS.md ("Releases") says so, and that the NuGet trusted publishing policy must leave its environment empty or name nuget.

The Maven Central job of the same run failed when it imported the GPG key (gpg exit code 2). That is the content of the MAVEN_GPG_PRIVATE_KEY secret, not the workflow.

v0.22.2

Choose a tag to compare

@github-actions github-actions released this 29 Nov 04:35
2db4044

Fixed

  • (bindings) Set the versions of the bindings' crates in their lock files

The first release run of the Bindings workflow failed: the native builds for Linux stopped at once with cannot update the lock file bindings/Cargo.lock because --locked was passed.

scripts/set-bindings-version.py, which a release runs before building, set the version of the bindings' crates (kakemono-bindings, kakemono-c, kakemono-jni, kakemono-node, kakemono-wasm) in their manifests but not in bindings/Cargo.lock and bindings/wasm/Cargo.lock. It now sets it there too; the library's own entry (kakemono) keeps its version. Pull requests never run this step, which is why their checks did not show it.

v0.22.1

Choose a tag to compare

@github-actions github-actions released this 29 Nov 04:21
1d2eef3

Build and CI

  • (bindings) Publish to NuGet with trusted publishing

The NuGet package of the .NET binding is now published with nuget.org's trusted publishing instead of a long-lived API key.

  • The NuGet job of .github/workflows/bindings.yml gets id-token: write and exchanges its GitHub OIDC token for a short-lived nuget.org key with NuGet/login (pinned to v1.2.0), as the account iamcaominhtien.
  • No NUGET_API_KEY secret is needed anymore. Instead, nuget.org holds a trusted publishing policy: GitHub Actions, repository iamcaominhtien/kakemono, workflow file bindings.yml.
  • docs/BINDINGS.md ("Releases") and the workflow's header say so.

Also fixed: scripts/release.py bump now writes the version into the lock files of the crates that use the library by path (python/Cargo.lock, bindings/Cargo.lock, bindings/wasm/Cargo.lock), not only into the root Cargo.lock. Without this, the bindings' cargo build --locked failed after every version bump (the JVM and .NET jobs of this pull request).

Nothing changes until BINDINGS_PUBLISH is true: the login and push steps run only when publishing.

v0.22.0

Choose a tag to compare

@github-actions github-actions released this 29 Nov 03:43
689f9ff

Added

  • Bindings for Node.js, WebAssembly, the JVM, .NET and C

kakemono can now be used from Node.js and TypeScript, browsers (WebAssembly), Java and Kotlin, C# and .NET, and C or C++, with the same API as the Python package. A Document is read and analysed once, then written to any output.

Packages

Language Package How it calls Rust
JavaScript, TypeScript (Node.js, Bun) @kakemono/node (npm) napi-rs 3, prebuilt for 8 platforms
JavaScript, TypeScript (browsers, workers, edge) @kakemono/wasm (npm, experimental) wasm-bindgen
Java 17+, Kotlin io.github.iamcaominhtien:kakemono, plus kakemono-native (one JAR per platform) and the optional kakemono-langchain4j JNI
C#, F# (.NET 8+) Kakemono (NuGet) P/Invoke over the C ABI
C, C++ include/kakemono.h and the kakemono_ffi library the C ABI itself

How the bindings share code:

  • All of them share one façade, bindings/core. It holds every option check and default, so each binding stays thin.
  • Options have the same camelCase names everywhere. A wrong option is refused with its name.
  • Each binding has its own README. docs/BINDINGS.md covers the layout, the shared behaviour, performance, building and releases.
  • The languages were chosen from a market survey and a comparison with Kreuzberg, written up in Vietnamese in docs/LANGUAGE-BINDINGS.md.

Stopping a conversion

Every binding can stop a call with the library's CancelToken (#41).

Binding How to stop Error when stopped
Node { signal, timeout } in the options of every call AbortError or TimeoutError
JVM a CancelToken and Options.timeout KakemonoException of kind CANCELLED or TIMED_OUT
.NET a CancellationToken on every call OperationCanceledException
C a KkCancel KK_ERROR_CANCELLED or KK_ERROR_TIMED_OUT
  • The call stops soon after the request, normally within a page.
  • The document stays usable afterwards.
  • WebAssembly cannot stop a call: its work is synchronous, and stopping would abort the module.

Changes to the library

  • New cargo features net (downloads, through ureq) and cli (clap and mimalloc). Both are on by default, so the default build is unchanged.
  • Without net, the library builds for wasm32-unknown-unknown. On wasm the clock reads 0 instead of panicking.
  • New public items: kakemono::VERSION and kakemono::add_font, which adds a font that layout and SVG text use.
  • With no font at all, laying out a document now fails with an error instead of panicking.
  • CancelToken now keeps the first cause of a stop. Before, a cancelled token whose deadline passed before the next check was reported as timed out.
  • Fix: a download that fails on its own cancellation is reported as Cancelled, in Python and in the bindings. Before, it came back as a document error.

Performance

Measured on 4 cores: 10 documents written as Markdown with jobs = 1, best of 3 runs.

Called from Rust C Node Java .NET WebAssembly
Seconds 6.77 6.67 7.01 7.43 6.93 8.42
  • Every binding gives the same Markdown, byte for byte.
  • Memory stays flat over thousands of rounds of open, write and close, in every binding.
  • Node runs at most one conversion per core at once (KAKEMONO_MAX_CONCURRENCY changes it). With this cap, 24 calls at once peak at 754 MB instead of 1.6 GB.

CI and releases

  • The Bindings workflow tests every binding on each pull request.
  • After a release, it builds the native libraries for Linux (glibc 2.17 and musl), macOS and Windows, on x86_64 and arm64.
  • It then assembles the npm, Maven and NuGet packages.
  • It publishes them only when the repository variable BINDINGS_PUBLISH is true and the registry secrets are set (docs/BINDINGS.md, "Releases"). Until then, the packages are only workflow artifacts.
  • SonarQube now measures the JVM binding: the SonarQube job builds the JNI library and runs the JVM tests with JaCoCo (mvn -Pcoverage verify). Its configuration leaves out the files that tools write (napi's loader and typings, cbindgen's header), and the bindings' tests join the test code that is not measured for coverage.

v0.21.0

Choose a tag to compare

@github-actions github-actions released this 28 Nov 09:19
af0078e

Added

  • Stop conversions with a CancelToken, and kakemono.aio for asyncio

Conversions can now be stopped, and the Python package can run them without blocking an asyncio event loop.

Stop a conversion: CancelToken

  • Rust: token.run(|| paper.analyze()) returns Err(Cancelled) soon after token.cancel() is called from another thread. CancelToken::with_timeout(..) sets a time limit and returns Cancelled::TimedOut.
    • The pipeline checks the token at its natural stopping points: each page, stage, block, table row, Word paragraph, sheet event and picture drawn.
    • The worker threads inherit the token, and downloads wait on a thread of their own.
    • No signature of the public API changes. Without a token, the output is the same byte for byte.
  • Python: every conversion takes cancel= and timeout=. A cancelled conversion raises kakemono.Cancelled, one past its time limit raises TimeoutError, and neither writes any file.

How long a conversion takes to stop after cancel(), cancelled at 8 points of each run:

Input Worst Median
8 arXiv papers, 6 output formats 151 ms 2–97 ms
Word → Markdown / PDF 98 / 418 ms 4–166 ms
Workbooks ≤ 100 ms (839 ms for a 21 s workbook) ≤ 580 ms
Web pages 123 ms ≤ 66 ms

The checks cost nothing measurable. Against the previous release, run alternately 7 times on PDFs, Word documents, workbooks and web pages, totals stay within −1.6% to +1.8%, inside the noise. A token, with or without a deadline, adds +0.6% to +0.8%, also inside the noise.

kakemono.aio: the functions to await

  • Every function has an awaited version with the same arguments: await aio.to_markdown("paper.pdf"). aio.Document.open reads a document once.
  • The work runs in a worker thread and the GIL is released, so several conversions run in parallel.
  • Cancelling the task, asyncio.wait_for or timeout= stops the conversion. The cancellation is raised only once the conversion has stopped, and at once for a conversion still waiting for a thread.
  • isolate=True runs a conversion in a Python process of its own. The process is killed when the task is cancelled or its time limit passes. This gives a hard limit for documents that are not trusted, and a process that crashes raises aio.ProcessError.
  • aio.pyi gives the typed signatures. It is written by scripts/make-aio-stub.py, and a test checks that it is current.

aio.convert_many: many documents into several formats

async for result in aio.convert_many(paths, "out", ["docx", "epub", "md", "pdf"], limit=50, timeout=120, isolate=False):
    print(result.source, result.outputs if result.ok else result.error or result.errors)
  • Each document is read once and written in every format asked for: html and the four modes, docx, md, tex, typ, epub, json, jsonl or pdf.
  • limit documents run at once, each with its own time limit, in threads or in isolated processes.
  • A result is yielded for each document as soon as it is done, with the files written and the error of each format or of the whole document. A document that fails does not stop the others.
  • It sets up its own threads: limit of them, with the cores shared out among the documents as jobs.
  • The README now says how many conversions the default executor runs at once, and how to run more.