russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.44k stars 600 forks source link

New feature: alert boxes #160

Open jakdept opened 9 years ago

jakdept commented 9 years ago

So, I'd like to get alert boxes added in - and I think using the syntax here. That'd make it look like:

Note! This is a note.
Attention: This text is important.

To be honest, I had thought about doing things another way also though - putting the ! at the start of the line, and then a : after the box type. That'd make it look like:

!Note: This is a note.
!Attention: This text is important.

Are there any better ideas for the syntax? Of course, the output, if HTML, should look like:

<div class='attention'>This text is important.</div>

Also, this isn't currently a markdown standard - at least not something I can find anywhere - but it seems like it's a fair addition to me.

I can fork and put this stuff in my own fork, but I'd rather stay on the main version if possible, so I wanted to bring this up.

Thanks

miekg commented 9 years ago

[ Quoting notifications@github.com in "[blackfriday] New feature: alert bo..." ]

So, I'd like to get alert boxes added in - and I think using the syntax here. That'd make it look like:

Note! This is a note.
Attention: This text is important.

To be honest, I had thought about doing things another way also though - putting the ! at the start of the line, and then a : after the box type. That'd make it look like:

!Note: This is a note.
!Attention: This text is important.

Are there any better ideas for the syntax? Of course, the output, if HTML, should look like:

<div class='attention'>This text is important.</div>

Also, this isn't currently a markdown standard - at least not something I can find anywhere - but it seems like it's a fair addition to me.

Leanpub markdown has syntax for this as well (https://leanpub.com/help/manual). It uses:

w> # Warning
w> 
w> this is a warning

etc.

/Miek

Miek Gieben

jakdept commented 9 years ago

I want/need these in a project I'm working on.

So, I implemented this in the most sensible way I could imagine - like what is listed above. I also wanted to make this stick out before being pre-processed. I implemented it in a fork, and as a quick example:

anything> This becomes a quote block, with the class anything-box added.

Expected output from that is something like:

<blockquote class='anything-box'>
<p>This becomes a quote block, with the class anything-box added.</p>
</blockquote>

I implemented this in a way to just piggy back off the blockquotes in markdown, but with a couple additional rules:

You have to set a flag to parse these tags (and not reject them as invalid blockquotes) and a second flag to display them.

In order to implement this, I had to change the signature of Renderer to accommodate accepting class names - so adding this would break everyone's different renderers - thus I don't know if/when you would want to merge this in. It's not in anyone's specification anyway.

I don't know if you want to merge this or not. If you decide you want to, I can create a pull request or whatever you need. Either way, thanks for an awesome tool :-)