protected override DirectiveBlock CreateFencedBlock()

in src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs [65:129]


	protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor)
	{
		var info = processor.Line.AsSpan();

		if (processor.Context is not ParserContext context)
			throw new Exception("Expected parser context to be of type ParserContext");

		var closingBracket = info.IndexOf('}');
		var directive = info[..closingBracket].Trim(['{', '}', '`', ':']);
		if (UnsupportedLookup.TryGetValue(directive, out var issueId))
			return new UnsupportedDirectiveBlock(this, directive.ToString(), issueId, context);

		if (info.IndexOf("{tab-set}") > 0)
			return new TabSetBlock(this, context);

		if (info.IndexOf("{tab-item}") > 0)
			return new TabItemBlock(this, context);

		if (info.IndexOf("{dropdown}") > 0)
			return new DropdownBlock(this, context);

		if (info.IndexOf("{image}") > 0)
			return new ImageBlock(this, context);

		if (info.IndexOf("{figure}") > 0)
			return new FigureBlock(this, context);

		if (info.IndexOf("{figure-md}") > 0)
			return new FigureBlock(this, context);

		// this is currently listed as unsupported
		// leaving the parsing in until we are confident we don't want this
		// for dev-docs
		if (info.IndexOf("{mermaid}") > 0)
			return new MermaidBlock(this, context);

		if (info.IndexOf("{include}") > 0)
			return new IncludeBlock(this, context);

		if (info.IndexOf("{literalinclude}") > 0)
			return new LiteralIncludeBlock(this, context);

		if (info.IndexOf("{settings}") > 0)
			return new SettingsBlock(this, context);

		foreach (var admonition in _admonitions)
		{
			if (info.IndexOf($"{{{admonition}}}") > 0)
				return new AdmonitionBlock(this, admonition, context);
		}

		foreach (var version in _versionBlocks)
		{
			if (info.IndexOf($"{{{version}}}") > 0)
				return new VersionBlock(this, version, context);
		}

		if (info.IndexOf("{stepper}") > 0)
			return new StepperBlock(this, context);

		if (info.IndexOf("{step}") > 0)
			return new StepBlock(this, context);

		return new UnknownDirectiveBlock(this, info.ToString(), context);
	}