Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
holm76 opened this issue Jun 22, 2023 · 2 comments
Open
Labels

Comments

@holm76
Copy link

holm76 commented Jun 22, 2023

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>
@xoofx xoofx added the question label Jul 8, 2023
@xoofx
Copy link
Owner

xoofx commented Jul 8, 2023

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.)

@holm76
Copy link
Author

holm76 commented Jul 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants