Document constructor

Document({
  1. Iterable<BlockSyntax>? blockSyntaxes,
  2. Iterable<InlineSyntax>? inlineSyntaxes,
  3. ExtensionSet? extensionSet,
  4. Resolver? linkResolver,
  5. Resolver? imageLinkResolver,
  6. bool encodeHtml = true,
  7. bool withDefaultBlockSyntaxes = true,
  8. bool withDefaultInlineSyntaxes = true,
})

Implementation

Document({
  Iterable<BlockSyntax>? blockSyntaxes,
  Iterable<InlineSyntax>? inlineSyntaxes,
  ExtensionSet? extensionSet,
  this.linkResolver,
  this.imageLinkResolver,
  this.encodeHtml = true,
  this.withDefaultBlockSyntaxes = true,
  this.withDefaultInlineSyntaxes = true,
}) : hasCustomInlineSyntaxes = (inlineSyntaxes?.isNotEmpty ?? false) ||
          (extensionSet?.inlineSyntaxes.isNotEmpty ?? false) {
  if (blockSyntaxes != null) {
    _blockSyntaxes.addAll(blockSyntaxes);
  }
  if (inlineSyntaxes != null) {
    _inlineSyntaxes.addAll(inlineSyntaxes);
  }

  if (extensionSet == null) {
    if (withDefaultBlockSyntaxes) {
      _blockSyntaxes.addAll(ExtensionSet.commonMark.blockSyntaxes);
    }

    if (withDefaultInlineSyntaxes) {
      _inlineSyntaxes.addAll(ExtensionSet.commonMark.inlineSyntaxes);
    }
  } else {
    _blockSyntaxes.addAll(extensionSet.blockSyntaxes);
    _inlineSyntaxes.addAll(extensionSet.inlineSyntaxes);
  }
}