Google apps script AppendListItem创建缺少图示符或缩进不正确的列表

Google apps script AppendListItem创建缺少图示符或缩进不正确的列表,google-apps-script,google-docs,document,Google Apps Script,Google Docs,Document,为了减少数小时的重复劳动,我尝试创建一个Google应用程序脚本,该脚本按顺序附加各种模板文档。该方法使用GoogleDocumentApp将多个模板文档中的各种元素附加到一个新文档中。这适用于除列表项之外的所有元素类型 DocumentApp将列表项从一个GDoc复制到另一个GDoc,但新项目符号显示时没有可见的标志符号/项目符号/编号,并且存在各种格式问题。我尝试过手动设置Glyph类型,正如类似的SO帖子所建议的那样,但是缩进有问题——当您调整新项目符号上的缩进时,在单击tab/shift

为了减少数小时的重复劳动,我尝试创建一个Google应用程序脚本,该脚本按顺序附加各种模板文档。该方法使用GoogleDocumentApp将多个模板文档中的各种元素附加到一个新文档中。这适用于除列表项之外的所有元素类型

DocumentApp将列表项从一个GDoc复制到另一个GDoc,但新项目符号显示时没有可见的标志符号/项目符号/编号,并且存在各种格式问题。我尝试过手动设置Glyph类型,正如类似的SO帖子所建议的那样,但是缩进有问题——当您调整新项目符号上的缩进时,在单击tab/shift tab时,它不会遵循通常的移入/移出模式。仅使用appendListItem时,不可见的图示符结果不一致

将模板GDoc复制到新创建的GDoc时,不会显示图示符。当复制到已经存在的GDoc(使用具有未知和不一致使用历史的文档多次测试)时,字形有时会出现。我怀疑问题出在appendListItem()或.copy()上——脚本中使用了这两个选项:

所用脚本的摘录:

thisBody.appendListItem(templateBody.getChild(i.copy())

我花了几个小时研究解决方法和这个问题的原因,但毫无结果。这似乎是一个尚未解决的已知问题。请告知。我犯了什么错误吗

恭敬地, -J

完整代码如下:

function appendTemplate(templateID) {
  var thisDoc = DocumentApp.getActiveDocument();
  var thisBody = thisDoc.getBody();
  
  var templateDoc = DocumentApp.openById(templateID); //Pass in id of doc to be used as a template.
  var templateBody = templateDoc.getBody();

  // Insert a Page Break between sections
  thisBody.appendPageBreak();
  
  // Append all body sections
  // Reference: https://stackoverflow.com/questions/54817801/google-docs-script-to-insert-another-document
  for(var i=0; i<templateBody.getNumChildren();i++){ //run through the elements of the template doc's Body.
    switch (templateBody.getChild(i).getType()) { //Deal with the various types of Elements we will encounter and append.
      case DocumentApp.ElementType.PARAGRAPH:
        thisBody.appendParagraph(templateBody.getChild(i).copy());
        break;
      case DocumentApp.ElementType.LIST_ITEM:    
        thisBody.appendListItem(templateBody.getChild(i).copy());
        break;
      case DocumentApp.ElementType.TABLE:
        thisBody.appendTable(templateBody.getChild(i).copy());
        break;
      case DocumentApp.ElementType.INLINE_IMAGE:
        thisBody.appendImage(templateBody.getChild(i).copy());
        break;
    }
  }
函数appendTemplate(templateID){
var thisDoc=DocumentApp.getActiveDocument();
var thisBody=thisDoc.getBody();
var templateDoc=DocumentApp.openById(templateID);//传入要用作模板的文档的id。
var templateBody=templateDoc.getBody();
//在节之间插入分页符
thisBody.appendPageBreak();
//附加所有正文部分
//参考:https://stackoverflow.com/questions/54817801/google-docs-script-to-insert-another-document

对于(var i=0;我不得不为我糟糕的英语技能道歉。不幸的是,从你的问题中,我无法理解你的现状和目标。为了正确理解你的现状和目标,你能提供示例输入、你当前的结果(包括问题)吗脚本和您期望的结果?这是否回答了您的问题?