diff --git a/code.js b/code.js index b852e6a..d938075 100644 --- a/code.js +++ b/code.js @@ -112,20 +112,21 @@ function processItem(item, listCounters, images) { prefix = "
  • "; suffix = "
  • "; } - - if (item.isAtDocumentEnd() || item.getNextSibling().getType() != DocumentApp.ElementType.LIST_ITEM) { - if (gt === DocumentApp.GlyphType.BULLET - || gt === DocumentApp.GlyphType.HOLLOW_BULLET - || gt === DocumentApp.GlyphType.SQUARE_BULLET) { - suffix += ""; - } - else { - // Ordered list (
      ): - suffix += "
    "; + + if (item && item.getNextSibling()) { + if (item.isAtDocumentEnd() || item.getNextSibling().getType() != DocumentApp.ElementType.LIST_ITEM) { + if (gt === DocumentApp.GlyphType.BULLET + || gt === DocumentApp.GlyphType.HOLLOW_BULLET + || gt === DocumentApp.GlyphType.SQUARE_BULLET) { + suffix += ""; + } + else { + // Ordered list (
      ): + suffix += "
    "; + } } - } - + counter++; listCounters[key] = counter; }