3 var repeat = require('repeat-string');
4 var pad = require('../util/pad');
6 module.exports = listItem;
8 /* Which checkbox to use. */
16 /* Stringify a list item.
18 * Prefixes the content with a checked checkbox when
23 * Prefixes the content with an unchecked checkbox when
28 function listItem(node, parent, position, bullet) {
30 var style = self.options.listItemIndent;
31 var loose = node.loose;
32 var children = node.children;
33 var length = children.length;
40 while (++index < length) {
41 values[index] = self.visit(children[index], node);
44 value = CHECKBOX_MAP[node.checked] + values.join(loose ? '\n\n' : '\n');
46 if (style === '1' || (style === 'mixed' && value.indexOf('\n') === -1)) {
47 indent = bullet.length + 1;
50 indent = Math.ceil((bullet.length + 1) / 4) * 4;
51 spacing = repeat(' ', indent - bullet.length);
54 value = bullet + spacing + pad(value, indent / 4).slice(indent);
56 if (loose && parent.children.length - 1 !== position) {