function convertListItemsToParagraphs() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var childIndex = 0;
while (childIndex < body.getNumChildren()) {
var child = body.getChild(childIndex);
if (child.getType() == DocumentApp.ElementType.LIST_ITEM) {
var listItem = child.asListItem();
var listItemText = listItem.getText();
var listItemIndex = listItem.getParent().getChildIndex(listItem);
// Add paragraph with the same text and attributes at the same index
body.insertParagraph(listItemIndex, listItemText).setAttributes(listItem.getAttributes());
listItem.removeFromParent();
} else {
childIndex++;
}
}
}
This script iterates through the child elements of the document’s body. If it encounters a list item, it converts it into a regular paragraph by extracting its text and inserting a new paragraph with the same text and formatting attributes. It then removes the original list item.