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

Where are the docs on how to extend Parsedown? #262

Closed
IngwiePhoenix opened this issue Jan 11, 2015 · 8 comments
Closed

Where are the docs on how to extend Parsedown? #262

IngwiePhoenix opened this issue Jan 11, 2015 · 8 comments

Comments

@IngwiePhoenix
Copy link

Hey.

I wanted to extend Parsedown, since it was stated to be possible in the Readme. But I could not find any docs on this matter... Where are these?

@erusev
Copy link
Owner

erusev commented Jan 11, 2015

I'm working on them.

What kind of an extension do you want to build?

@IngwiePhoenix
Copy link
Author

I wamt to change a chat system from using BBCode to markdown, but I want to add a color-code:

{c:black}my text{/c}
{c:#ffffff}my text{/c}

should turn into:

<span style="color:$c“>$text</span>

Am 11.01.2015 um 15:07 schrieb Emanuil Rusev notifications@github.com:

I'm working on them.

What kind of an extension do you want to build?


Reply to this email directly or view it on GitHub #262 (comment).

@erusev
Copy link
Owner

erusev commented Jan 11, 2015

I can give you some directions.

What you describe is an inline element. Most inline elements have markers. Markers are the first character of inline elements. In the case of your inline element, the marker is {.

Here's what you could do:

  1. In the constructor of your extension, add an element to the $this->InlineTypes array. The key of that element should be the marker of your inline element ({) and the value should be the name of your inline element (e.g. ColoredText);
  2. Create a method named inlineColoredText. This method will get called whenever the parser finds the marker { in the text.
  3. Have a look at the other inline... methods to figure out how to implement it.

@IngwiePhoenix
Copy link
Author

Okay, thanks! Ill go ahead and check this out. :)
Thanks for the hints. ^^

Am 11.01.2015 um 15:42 schrieb Emanuil Rusev notifications@github.com:

I can give you some directions.

What you describe is an inline element. Most inline elements have markers. It's the first character of the inline element. In the case of your inline element, the marker is {.

Here's what you need to do:

In the constructor of your extension, add an element to the $this->InlineTypes array. The key of that element should be the marker of your inline element (i.e. {) and the value should be the name of your inline element (e.g. ColoredText);

Create a method named inlineColoredText. This method will be called whenever the parser finds the marker { in texts.

Have a look at the other inline... methods to figure out how to implement it.


Reply to this email directly or view it on GitHub #262 (comment).

@erusev
Copy link
Owner

erusev commented Jan 11, 2015

More specifically, have a look at the implementation of the strikethrough inline element and the inlineStrikethrough method. It seems to be the closest to the element that you want to implement.

@hkdobrev
Copy link
Contributor

I don't want to be over pedantic, but this is at least related if not duplicate of #159.

@erusev
Copy link
Owner

erusev commented Jan 12, 2015

@hkdobrev This is true. I'm closing this issue in favour of the other one.

@erusev erusev closed this as completed Jan 12, 2015
@erusev
Copy link
Owner

erusev commented Jan 15, 2015

I included and implementation of this in the wiki. You should check it out.

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

3 participants