NAME
Angerwhale::Format - Dispatches formatting of posts/comments to sub-modules
SYNOPSIS
EXTENSIONS
A Angerwhale::Format extension is simple to write. It needs the following routines:
new
Initialize the formatter. Returns a blessed reference, or dies on failure.
can_format(type)
This method will be called with the "type" to format. Return 0 if you can't handle it, or a higher number based on how well you can format the "type". 1 is the lowest, 100 is the highest.
format(text, type)
This method will be called if your module returned the highest value for can_format
. It is passed the text to format, and the type. It should return the text formatted as HTML.
Alternatively, you may return an Angerwhale::VirtualComment.
format_text(text, type)
Like format
, but return plain text instead of HTML. If format_html or format returns a VirtualComment, this method should return the same one.
format_html
Alias.
types
Returns a list of hashrefs, where each hashref consists of:
- type
-
The name of the type, i.e. the name that
can_format
will accept. - description
-
The human-readable description of the type.