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,
  9. bool checkable = false,
  10. bool preserveSpace = false,
  11. dynamic options,
  12. BlockParserBuilder blockParserBuilder = BlockParser.new,
  13. InlineParserBuilder inlineParserBuilder = InlineParser.new,
})

Implementation

Document({
  Iterable<BlockSyntax>? blockSyntaxes,
  Iterable<InlineSyntax>? inlineSyntaxes,
  ExtensionSet? extensionSet,
  this.linkResolver,
  this.imageLinkResolver,
  this.encodeHtml = true,
  this.withDefaultBlockSyntaxes = true,
  this.withDefaultInlineSyntaxes = true,
  this.checkable = false,
  this.preserveSpace = false,
  this.options,
  BlockParserBuilder blockParserBuilder = BlockParser.new,
  InlineParserBuilder inlineParserBuilder = InlineParser.new,
}) : hasCustomInlineSyntaxes = (inlineSyntaxes?.isNotEmpty ?? false) ||
          (extensionSet?.inlineSyntaxes.isNotEmpty ?? false),
    _blockParserBuilder = blockParserBuilder,
    _inlineParserBuilder = inlineParserBuilder {
  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);
  }
}