Detecting Track Changes Markup In Documents

Before a document is published outside of a content management system, it is good policy to ensure that all track changes data has been handled - either accepting or rejecting the changes. While it's easy for users to select "Accept All" before publishing, it is often useful to include a check before publishing to ensure that changes haven't slipped through.

Detecting the presence of change information is simple, any document with track changes data includes a "trackchanges" element in a hidden div at the end of the body. In nearly all cases you can just check if the string "<trackchanges " is present in the document. In rare cases where there is a custom tag called "trackchanges" in the document, you may need to additionally check for the presence of the DIV before the trackchanges element.

In JavaScript you can implement this check with the code:

var hasChangeData = documentContent.indexOf("<trackchanges ") >= 0;

where the documentContent variable contains the content of the document. We'll be publishing a tip on stripping out the track changes data automatically when publishing, without having to first load it into the editor.

Adrian spends his days working out ways to make life easier for Ephox clients through initiatives like LiveWorks! Previously a senior engineer, he has now moved on to the fancier sounding title of CTO.

3 Responses to “Detecting Track Changes Markup In Documents”

  1. Ephox LiveWorks! » Accepting All Changes With XSLT Says:

    [...] have been accepted, before you push the document out to the world. We've previously shown how you can detect that change information is present, but we can go one step further and remove that information and publish the document as if all the [...]

  2. Ephox LiveWorks! » Accepting All Changes With JavaScript Says:

    [...] previous installments we've looked at ways to detect the presence of track changes data and accept the changes using XSLT. This time round, we'll use JavaScript string parsing to [...]

  3. Ephox LiveWorks! » Track Changes and Express Edit Says:

    [...] Detecting Track Changes Markup In Documents [...]

Leave a Reply