How to copy ListItems from one Google Document to another while preserving numbering?
<p>The accepted answer to <a href="https://stackoverflow.com/questions/19987101/how-to-copy-content-and-formatting-between-google-docs">How to copy content and formatting between Google Docs?</a> indicates that we have to add conditional code just to copy elements. But I cannot get it to work for ListItem types, because the target document shows the list items without the original numbering. </p>

<pre class="lang-js prettyprint-override"><code>var source_doc = DocumentApp.getActiveDocument();
var selection = source_doc.getSelection();
if (!selection) {
    var ui = DocumentApp.getUi();
    ui.alert('Please make a selection first.');
    return;
}

var target_doc = DocumentApp.create('CopyOf'+DocumentApp.getActiveDocument().getName());
var target_body = target_doc.getBody();

var elements = selection.getRangeElements();
for (var i = 1; i &lt; elements.length; i++) {
    var source_element = elements[i].getElement();
    var copy_element = source_element.copy();
    if (copy_element.getType() == DocumentApp.ElementType.PARAGRAPH) {
        target_body.appendParagraph(copy_element);
    } else if (copy_element.getType() == DocumentApp.ElementType.LIST_ITEM) {
        // This does not keep the numbering on the list item. Why?
        target_body.appendListItem(copy_element);

        // And playing games with setListId doesn't work either:
        // copy_element.setListId(source_element);
        // target_body.appendListItem(copy_element);
    }
    // TODO: Handle the other elements here.
}
</code></pre>

<p>The source document displays like this:</p>

<p><a href="https://i.stack.imgur.com/ArM95.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ArM95.png" alt="source document"></a></p>

<p>Target document renders like this:</p>

<p><a href="https://i.stack.imgur.com/rtM1n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rtM1n.png" alt="bad rendering"></a></p>

<p>How do I preserve ListItem formatting?</p>

<p>This seems much much harder than it should be: What I really want is to copy the users selection verbatim into a new document preserving all formatting, and from a google script.</p>

<p>It would seem that this could be done at a higher level.  I can manually copy and paste and preserve the formatting, just not from the script.</p>