use of com.vladsch.flexmark.util.collection.iteration.Reverse in project flexmark-java by vsch.
the class IndentedCodeBlockParser method closeBlock.
@Override
public void closeBlock(ParserState state) {
// trim trailing blank lines out of the block
if (trimTrailingBlankLines) {
int trailingBlankLines = 0;
List<BasedSequence> lines = content.getLines();
for (BasedSequence line : new Reverse<BasedSequence>(lines)) {
if (!line.isBlank())
break;
trailingBlankLines++;
}
if (trailingBlankLines > 0)
block.setContent(lines.subList(0, lines.size() - trailingBlankLines));
else
block.setContent(content);
} else {
block.setContent(content);
}
if (codeContentBlock) {
CodeBlock codeBlock = new CodeBlock(block.getChars(), block.getContentLines());
block.appendChild(codeBlock);
}
content = null;
}
Aggregations