Labels as markdown

Labels are a great general purpose UI element, also pure css:

If there was a markdown extension for labels, they could be inserted into posts via the tool bar or markup:

[label style=default]My cool label[/label]

Any takers?

Should be relatively easy to create a plugin to do that.

If good old pirate speak still works, it’d be a good basis. I’m pretty sure that the plugin tutorial is out of date, but pirate-talk was updated relatively recently, so it might work.

3 Likes

Sweet.

Looks like the function below is the one to edit. So if I rewrite the regex to recognize the tags [label] and [/label], replace those by <span class='cool_label'> and </span>; then add the css class in the customization tab; that should do it right? Anything else I need to do to ensure html tags get rendered?

function piratize (text) {
  return text.replace(/\b(am|are|is)\b/ig, "be")
             .replace(/ing\b/ig, "in'")
             .replace(/v/ig, "'");
}

Beats me. I think it should work, though.

I did go so far as to install the plugin and make sure it works. Real Soon Now, I’ll fix my DOI resolver plugin.

1 Like

Actually, it would be better to look at the formatting toolbar plugin, as it will show you how to add a toolbar item and how to whitelist tags/classes.

5 Likes