Skip to content

v8.9.0: 🧩 Macro-Enabled Files, Templates & Tidier HTML and Markdown

Latest

Choose a tag to compare

@github-actions github-actions released this 18 Nov 09:22

v8.9.0: 🧩 Macro-Enabled Files, Templates & Tidier HTML and Markdown

I am pleased to announce the release of officeParser v8.9.0! Word's, Excel's and PowerPoint's macro-enabled files, templates and slideshows are read, a footnote with id 0 is kept, HTML can leave out footnote back-links and give each sheet a header row, Markdown writes a column aligned paragraph by paragraph as the column's alignment, and pdf.js moves to 6.5.438.

Warning

Behavior changes

  • Markdown column alignment comes from the cells' paragraphs. A column whose cells each hold one paragraph, all centred or all right-aligned, is now written as :---: or ---: with plain cells, where each cell was a <div style="text-align: ..."> under | --- |. Columns holding anything else keep each cell's own alignment.
  • Under sheetLayout: 'tables' a sheet's heading has one id, from its text (<h2 id="visits">), as every other heading's is. The sheet-N id and the empty anchor before the heading are gone.
  • Browsers loading their own PDF worker point pdfWorkerSrc at pdfjs-dist@6.5.438's pdf.worker.min.mjs.

🌟 Key Highlights

1. Macro-enabled files, templates and slideshows (#161)

.docm, .dotx, .dotm, .xlsm, .xltx, .xltm, .pptm, .potx, .potm, .ppsx and .ppsm were refused as unsupported, by file name and from a buffer, though only their main part's content type differs from a DOCX's, XLSX's or PPTX's. Each is now read as its document is, and fileType takes their names. Their macros are not read. Thanks to @AButtiens for the report.

2. A footnote or endnote with id 0 is kept (#160)

Separator notes were told apart by their ids, -1 and 0, as Word numbers them, so a file whose first real note has id 0 (as WPS Office writes) lost it. Separators are now told apart by their type. Thanks to @AButtiens for the report.

3. Footnotes without back-links, and sheets with header rows

await ast.to('html', { htmlConfig: { footnoteBackLinks: false } });  // notes without the ↩ link
await ast.to('html', { htmlConfig: { sheetLayout: 'tables', sheetHeaderRow: 'first' } });
  • footnoteBackLinks: false writes each footnote and endnote with its own content only, for a host that keeps a note's markup as its text. On by default.
  • sheetHeaderRow: 'first' makes each sheet's first row its header row under sheetLayout: 'tables', so a sheet of column names becomes a table with a header, and its Markdown a proper GFM table.

4. Markdown tables keep their column alignment

A table whose cells each hold one centred or right-aligned paragraph is now written as the column's alignment instead of HTML in every cell. The header's left-aligned paragraph makes the column :---, and cells that show nothing are passed over.


🔧 Also Fixed

  • HTML: a header row with empty columns keeps its cells in their columns. In a sheet's table, a header row's cells after an empty column were written a column to the left.
  • PDF: pdf.js 6.5.438, with what PDFs read as unchanged, and each font's data let go once it is bound, so long documents with many fonts stay lean.

See the full list in the changelog.


🛠 Getting Started

npm install officeparser@8.9.0

🔗 Full Changelog: View v8.9.0 details
🔗 Documentation & Visualizer: officeparser.harshankur.com