@Override
public int processLineContent(String line,int offset) {
if (blockLineCount == 0) {
listState = new Stack<ListState>();
Attributes attributes = new Attributes();
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
BlockType type = calculateType(listSpec);
if (type == BlockType.BULLETED_LIST && "-".equals(listSpec)) {
attributes.setCssStyle("list-style: square");
}
// 0-offset matches may start with the "*** " prefix.
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
listState.push(new ListState(1,type));
builder.beginBlock(type, attributes);
adjustLevel(listSpec, level, type);
} else {
Matcher matcher = startPattern.matcher(line);
if (!matcher.matches()) {
setClosed(true);
return 0;
}
String listSpec = matcher.group(1);
int level = calculateLevel(listSpec);
BlockType type = calculateType(listSpec);
offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
adjustLevel(listSpec, level, type);
}
++blockLineCount;
ListState listState = this.listState.peek();
if (listState.openItem) {
builder.endBlock();
}
listState.openItem = true;
builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
dialect.emitMarkupLine(getParser(),state,line, offset);
return -1;
}