function generateInstrumentedHTML(editor) {
        var doc = editor.document,
            dom = scanDocument(doc),
            orig = doc.getText(),
            gen = "",
            lastIndex = 0;

        if (!dom) {
            return null;
        }

        // Ensure that the marks in the editor are up to date with respect to the given DOM.
        _markTextFromDOM(editor, dom);

        // Walk through the dom nodes and insert the 'data-brackets-id' attribute at the
        // end of the open tag
        function walk(node) {
            if (node.tag) {
                var attrText = " data-brackets-id='" + node.tagID + "'";

                // Insert the attribute as the first attribute in the tag.
                var insertIndex = node.start + node.tag.length + 1;
                gen += orig.substr(lastIndex, insertIndex - lastIndex) + attrText;
                lastIndex = insertIndex;
            }

            if (node.isElement()) {
                node.children.forEach(walk);
            }
        }

        walk(dom);
        gen += orig.substr(lastIndex);

        return gen;
    }
Generate instrumented HTML for the specified editor's document, and mark the associated tag
ranges in the editor. Each tag has a "data-brackets-id" attribute with a unique ID for its
value. For example, "<div>" becomes something like "<div data-brackets-id='45'>". The attribute
value is just a number that is guaranteed to be unique.

Also stores marks in the given editor that correspond to the tag ranges. These marks are used
to track the DOM structure for in-browser highlighting and live HTML updating.

This only needs to be done once on load of a document. As the document is edited in memory,
the instrumentation is kept up to date via the diffs and edits that are generated on change
events. Call this again only if you want to do a full re-sync of the editor's DOM state.

@param {Editor} editor The editor whose document we're instrumenting, and which we should
    mark ranges in.
@return {string} instrumented html content