# All files / src/lib/markdown-it/plugins/markdown-it-block-embed index.ts

100% Statements 8/8
75% Branches 3/4
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36

    22x
    22x
    22x

    22x
    35x
    35x

    35x

    35x

     // Copyright (c) Rotorz Limited and portions by original markdown-it-video authors
    // Licensed under the MIT license. See LICENSE file in the project root.

    import MarkdownIt from 'markdown-it';

    import PluginEnvironment from './PluginEnvironment';
    import renderer from './renderer';
    import { createTokenizer } from './tokenizer';

    export type UrlFilterDelegate = (
      url: string,
      serviceName: string,
      videoID: string,
      options: BlockEmbedOptions
    ) => string;

    export interface BlockEmbedOptions {
      containerClassName?: string;
      serviceClassPrefix?: string;
      outputPlayerSize?: boolean;
      allowFullScreen?: boolean;
      filterUrl?: UrlFilterDelegate | null;
      services?: Record<string, any>;
      [serviceConfig: string]: any;
    }

    export default function setup(md: MarkdownIt, options?: BlockEmbedOptions) {
      const normalizedOptions: BlockEmbedOptions = options ?? {};
      let env = new PluginEnvironment(md, normalizedOptions);

      md.block.ruler.before("fence", "video", createTokenizer(env.services), {
        alt: [ "paragraph", "reference", "blockquote", "list" ]
      });
      md.renderer.rules["video"] = renderer.bind(env);
    }