3 ms·
Sounds to good to be true, but it works for the given examples! What is the scope though? It produces garbage with larger documents with tables and figures. Fo
by exceptione 3mo ago
Sounds to good to be true, but it works for the given examples!
What is the scope though? It produces garbage with larger documents with tables and figures. For example this large document, even with removed menu and headings: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html-single/managing_storage_devices/index https://docs.redhat.com/en/documentation/red_hat_enterprise_...
Could it be it has only been fed small documents?
- fishbone 3mo agoAll of the suite test cases are small fragments of HTML to test specific things, so I probably do need a way to test bigger documents. Thanks for the feedback. I’ll add that to the to-do list. I’ll try the red hat example later this evening.
- fishbone 3mo agoOk, I dug into the Red Hat doc. It’s a great example and it uncovered a few real shortcomings. A couple of things about this scenario: First, the page relies on stylesheets, so you need styleSource: "computed", either Playwright on Node, or run in the browser with the content already rendered. Second, dom-docx doesn’t fetch remote images itself. The caller supplies an imageResolver (e.g. a fetch callback), which keeps security, timeouts, host allowlists, etc. under caller control: https://dom-docx.com/learn#image-resolver https://dom-docx.com/learn#image-resolver I fixed a few bugs from this (in 0.1.8): - wide headings inside flex containers getting clipped - oversized images not scaling down to the printable page width - OS dark theme (prefers-color-scheme: dark) leaking near-white computed text colors into Word on the browser path I also added an ad-hoc repo script that loads a live URL, takes a CSS selector, and converts with Playwright (tools/try-url.ts). I used it on the RHEL page and got a pretty decent 200+ page doc. Some tables still look wrong — I’ll dig into those next. Script: https://github.com/floodtide/dom-docx/blob/main/tools/try-url.ts https://github.com/floodtide/dom-docx/blob/main/tools/try-ur... Example usage from a clone: npx tsx tools/try-url.ts \ "https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html-single/managing_storage_devices/index https://docs.redhat.com/en/documentation/red_hat_enterprise_..." \ ".docs-content-container" \ rhel-storage.docx
- exceptione 3mo agoThanks for following up. I don't understand why your post has been flagged.