renderInlines method

  1. @visibleForTesting
String renderInlines(
  1. List<DeltaInsertOp> ops, [
  2. bool isInlineGroup = true
])

Implementation

@visibleForTesting
String renderInlines(List<DeltaInsertOp> ops, [bool isInlineGroup = true]) {
  final int opsLen = ops.length - 1;
  final String html = ops.mapIndexed((int i, DeltaInsertOp op) {
    if (i > 0 && i == opsLen && op.isJustNewline()) {
      return '';
    }
    return _renderInline(op, null);
  }).join('');
  if (!isInlineGroup) {
    return html;
  }

  final String startParaTag = makeStartTag(_converterOptions.paragraphTag);
  final String endParaTag = makeEndTag(_converterOptions.paragraphTag);
  if (html == brTag || _options.multiLineParagraph == true) {
    return startParaTag + html + endParaTag;
  }

  return startParaTag + html.split(brTag).map((String v) => v.isEmpty ? brTag : v).join(endParaTag + startParaTag) + endParaTag;
}