Creating custom tags - Arcath/Markabb GitHub Wiki

Creating custom tags is simple with Markabb.

To add a custom tag just after your cofiguration block add this line:

Markabb.register_tag :name, Markabb::Tag.new(/foo/, 'bar')

Grouping

register_tag has an optional 3rd argument that allows you to group similar tags, for example all the tags like [b] and [i] are in the group formatting which means that you can disable whole groups in the same way you disable indavidual tags.

Tag Object

The Markabb::Tag object that you pass as the the second argument takes 2 options, the first is a matcher for the tag and the second is the replacement.

The matcher can be either a regex pattern or a string.

Regex Tag

If the first parameter passed is a regex pattern then it is used without modification to run the tag. For example the bold tag looks like this:

Markabb::Tag.new(/\[b\](.*?)\[\/b\]/, '<b>\1</b>')

String Tag

If the tag you want to add is a simple wrapper tag like the bold tag you can pass a string instead of a regex pattern. So to do the same as the regex example above you would use:

Markabb::Tag.new('b', '<b>\1</b>')
⚠️ **GitHub.com Fallback** ⚠️