Support for alert/warning boxes

I haven’t seen support for Alert Boxes in any official specifications, and I’d find them useful when used appropriately. I’m looking for something functionally similar to this or this.

I used a couple of different things in the past, and finally wrote something into one engine that I’m using because I needed it for something, but I’d like to see official support.

I’d like to propose support for the addition of alert boxes. I’m happy with whatever syntax everyone wants, but as a starting point, the way I did this was to just augment the blockquote syntax:

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:

  • classes can only contain US characters A-Z or a-z
  • I didn’t want to monkey with é being one byte or two
  • there cannot be a space between the class type and the > for the blockquote
  • alert> is valid, alert > is not

I’m happy to consider other alternatives for doing this - mdwiki.info uses the syntax:

warning: The contents of this box are a warning.

And only triggers on specific keywords. I wanted to avoid trigger keywords, and allow people to do as much as they want in their CSS, so I tried being as generic as I could without getting to complex.

Thoughts? Better ways to do this?

You might look at my comment here.

I’ll gladly admit - I poked and scanned through the thread there, but I did not read the whole thing. Still, I think (I hope) I got an idea of what you’re saying.

I’m completely for using whatever syntax everyone wants. I wrote something (the stuff above), and it’s what I’ll use for now (it’ll work for me for now), but it’s non-standard. I would rather know the proper standard for those, or have a standard.

I like blockquotes - I think they bring value to markdown. I also think they could be extended in a generic fashion somehow, and by doing so, you could in turn have that extra bit support a lot of stuff. For example, moving away from alert/warnings, spoilers could simply be:

spoiler> This is a spoiler.

And of course, once again, that’s sticking with the standard I already implemented. Whatever is decided is fine - I can re-implementing what I already did. I tried to do them following the current blockquote as much as possible, and tried stealing influence from the opening/closing code blocks - but I’m happy to admit there are lots of other ideas that probably fit better.

Of course, as I believe you mentioned in that other thread, I do like the idea of using something other than the below example that’s thrown around in that thread, as it’s not really extensible:

!> This is a spoiler

Also, of course, if I should just merge this into the other thread you linked, I can. I’ll be honest, I’m new to this system, but I’m happy to do whatever is proper per style guidelines, and happy to figure out how to do that on my own. :smile: I’m also sorry that I did not find that thread to being with :confused: but I’ll lean on whatever grace that newcomers get around here. :smile:

Also relevant - I took a further look at the other thread.

!warning> This is a warning. It spans
!warning> multiple lines.

Or this:

.WARNING
> This is a warning. It spans
> multiple lines.

Would work just fine I would think - I see no problems and both could be applied to many different things.

I suspect warning could be substituted for warning\-box also - or characters of any language could be used - US letters was easiest to implement for me for now.

I saw the following mentioned in the other thread - I don’t understand how the following is supposed to work, but if it’s what is settled on, I can work with that.

> This is a warning. It spans
> multiple lines.
{: class=warning}

To be honest, I just want a standard I can implement and use. :smile:

Did you read the comment I linked you to? The point of the comment was that things like spoilers and alert/warning boxes can easily be achieved without any alterations to syntax, using some simple conventions and a custom renderer or AST transformation. An additional advantage of this approach is that the content degrades nicely when viewed with bog-standard Markdown renderers. It’s something worth considering. I think people jump much too quickly to the conclusion that they need some kind of syntax extension.

1 Like

JFTR, there are some deployed extensions that support something like this.

Leanpub-flavored markdown / Markua use a similar approach with single letters:

W> This is a warning.

“Markdown 2” uses double square brackets and standard Bootstrap class names:

[[ This is an alert. ]]

Other existing markdown implementations use other incompatible syntax for generic blocks with classes applied to them:

> %class%
> prefixed block
::: class
fenced block
:::
!!! class
    indented block

@JackKnifed FYI, there has already been multiple discussions about how block elements such as warning boxes should be implemented. I’ve listed them on the Proposed Extensions wiki page under “Directives”.

1 Like

That’s fairly helpful, as is what @Crissov mentioned

As mentioned right above, different projects have even more standards for this. I started by looking at learnpub for my method, but thought that a single letter was not descriptive enough, so went further than that. That’s the way I implemented this in one place - and it’s another alternative implementation (which probably makes the problem worse).

Instead of having 50 different divergent ways of doing this, it would be nice to have one unified way to do a lot of stuff like this - accepted by CommonMark. I’d think doing so would make it the “right way” by definition, and give everyone a unified target to work towards.