Skip to content

Add Custom Markdown Parser Block and Inline Injection #1767

@WilliamABradley

Description

@WilliamABradley

I'm submitting a...

  • Feature request

Description

Injection

I plan to work on this after #1650 is merged.

We are never going to cover everyone's Markdown Standards, so we should create a way to let the User define their own parsing Rules, Block, Inlines, Conditions, etc.

The current way I'm thinking of implementing this, is by having an event called ParsingBeginning, or something similar, in the Args for that event would be the Registered TripChars and ways of Identifying Blocks.

This way you can Add, Insert, and Remove registration for Block and Inline Creation. If, for some reason you want to disable List Block parsing, it could be done with this event.

You could then create your own Inlines to handle with your own custom logic and UI.

Rendering

To implement UI for this, new methods would be added to the MarkdownRendererBase.

public override void RenderCustomBlock(MarkdownBlock block, IRenderContext context)
{
    switch (block)
    {
        case CustomBlockType1 custom1:
            RenderCustomBlockType1(custom1, context);
            break;

        default:
            base.RenderCustomBlock(block, context);
            break;
    }
}

public override void RenderCustomInline(MarkdownInline inline, IRenderContext context)
{
    switch (inline)
    {
        case CustomInlineType1 custom1:
            RenderCustomInlineType1(custom1, context);
            break;

        default:
            base.RenderCustomInline(inline, context);
            break;
    }
}

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions