mammoth.js icon indicating copy to clipboard operation
mammoth.js copied to clipboard

[Question] Is there a way to get document "tracked changes"?

Open devgeni opened this issue 2 years ago • 5 comments
trafficstars

Hey! Great lib. I wonder if I could also somehow get the tracked changes while converting the document.

Well, I have a document with "Track Changes" enabled. And when I tried to convert it using transformDocument function I didn't see any additional data that might belong to those tracked changes.

So, is this possible? Or maybe it'll be possible in the future?

devgeni avatar Jan 04 '23 13:01 devgeni

Could you provide a minimal example document, the HTML you'd like to get, and the HTML you're actually getting?

mwilliamson avatar Jan 04 '23 21:01 mwilliamson

Oh, I guess you might have misunderstood me. The conversion, the default conversion works fine, I don't have any issue with that. What I actually want is to be able to show the "tracked changes" of Microsoft Document in HTML. So to achieve that I tried to customize the conversion with the help of transformDocument option. I looked into the elements that are handled by transformDocument option and I didn't find any "Track Changes" data there. I suppose this data is inside .docx file. But I didn't see this data in transformDocument option function. I just console.log the element in the transformDocument function, but the element only has the latest "text" object.

const mammoth = require("mammoth");

function transformElements(element) {
  console.log(JSON.stringify(element));
  return element;
}

mammoth.convertToHtml({ path: "tracking-changes.docx" }, {
  transformDocument: transformElements
}).then(console.log).done();

The document with "Track Changes" enabled: tracking-changes.docx

Looks like: image

I would like to convert it to:

<p>H<del>ello</del><ins>i all</ins>.</p>

Is this possible?

devgeni avatar Jan 05 '23 13:01 devgeni

+1

DioNNiS avatar Jan 05 '23 18:01 DioNNiS

Is this possible?

Not at the moment, no.

mwilliamson avatar Jan 05 '23 18:01 mwilliamson

Can we fix it?

DioNNiS avatar Jan 05 '23 22:01 DioNNiS