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

adding custom rules at runtime #750

Closed
ciel opened this issue May 15, 2016 · 3 comments
Closed

adding custom rules at runtime #750

ciel opened this issue May 15, 2016 · 3 comments

Comments

@ciel
Copy link

ciel commented May 15, 2016

I am using marked to render Markdown in an application, but I have a situation where I want to create some 'custom' renderings - similar to the way gimmicks are used in md-wiki.

I want to add some custom rules, such as the following;

[!alert:warning] > some text goes here as a warning
[!alert:success] > some text goes here as success

And have it render output like...

<blockquote class="alert warning">Some text goes here as a warning</blockquote>
<blockquote class="alert success">Some text goes here as success</blockquote>

I've seen that I can do this in marked by adding to the rules on the block literal, but this requires me to hard-code them into the actual library. Is there a way to add a rule to marked at runtime, that can allow me to leave the core library alone?

@lejafar
Copy link

lejafar commented Aug 17, 2016

You could use the overriding methods to change the way a link is rendered depending on the link text just like md-wiki does.

@rubencodes
Copy link

rubencodes commented Aug 30, 2016

I think instead of overriding an existing method, what OP wants is to define a custom rule.
e.g. All existing rules should stay the same, but maybe { some text } (or something similar) has a custom behavior.

Maybe this is relevant? #504

@joshbruce
Copy link
Member

The focus right now is to correct for targeted specifications before revisiting extensibility.

See #956

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

No branches or pull requests

4 participants