markdig icon indicating copy to clipboard operation
markdig copied to clipboard

Created a custom InlineParser but it seems other parsers are not processing

Open holm76 opened this issue 1 year ago • 2 comments

I'm in the process of writing a custom parser and renderer for custom Alert blocks and I sort of have it working using InlineParser and HtmlObjectRenderer.

But when I have my extension added to the pipeline it seems other parsers are not running or rather some parsers are not running.

In my resulting HTML I do get < p >s everywhere but If I add a strong to my alert text it does not get the tags. If I do not add my extension to the pipeline I do get a tag on my HTML.

Is there something special I need to do to make that work?

This is the syntax I have chosen, Maybe its not good?

markdown = @"¤Tip|This is a tip alert and this text should be strong however it is not if my extension is loaded";

With my extension off:

<p>Tip|This is a tip alert and this text should be <strong>strong</strong> however it is not if my extension is loaded</p>

With my extension on:

<p><div class="alert alert-success" role="alert">
    <p class="alert-title">
        <strong>
            <i class="bi bi-lightbulb"></i>
            Tip
        </strong>
    </p>
        <p class="mb-0">This is a tip alert and this text should be **strong** however it is not if my extension is loaded</p>
</div></p>

holm76 avatar Jun 22 '23 11:06 holm76

Is there something special I need to do to make that work?

Difficult to say, but when you say renderer for custom Alert blocks, and you are using an inline parser, you might instead use a block parser. Inline parsers have other constraints in order to work with other parsers (e.g starting characters, when to end, parsing precedence with other parsers...etc.)

xoofx avatar Jul 08 '23 16:07 xoofx

I may not have written my extension correctly!

I've solved it by running the parser twice. First without my custom extension and then with my extension added and then I get the result I'm looking for.

It's most likely not optimal but for now it works.

What I'm trying to do is replicate the way that other documentation sites are building those Bootstrap Alert boxes by types of Notes, Tips, Warnings and Cautions and the like. The text inside those alerts also need to be checked for strong and italic constructs so I have no idea if I should be using an Inline or a Block type parser.

By parsing twice I now get the strong and italic parsing done right and after that I get my Alerts built correctly.

holm76 avatar Jul 10 '23 12:07 holm76