GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MojoMojo::Formatter(3) User Contributed Perl Documentation MojoMojo::Formatter(3)

MojoMojo::Formatter - Base class for all formatters

    package MojoMojo::Formatter::Simple;

    use parent qw/MojoMojo::Formatter/;

    sub format_content_order { 14 }
    # so that it runs after inclusion of obscene web sites
    # (MojoMojo::Formatter::Include runs at 6)

    sub format_content {
        my ($class, $content, $c) = @_;
        $$content =~ s/fuck/f**k/g;
        return $content;
    }

This is the class to inherit from if you want to write your own formatter.

See the synopsis for a really simple formatter example. MojoMojo uses Module::Pluggable::Ordered to process all the formatter plugins. Just specify when you want to trigger your formatter by providing a format_content_order method which returns a number to specify when you want to run. The plugin order for the default plugins is currently as follows:
1 - MojoMojo::Formatter::Redirect - handles {{redirect /path}}
5 - MojoMojo::Formatter::Include - handles {{include <url>}} before all other plugins, so that transcluded sections from the same wiki get parsed for markup
10 - MojoMojo::Formatter::CPANHyperlink - handles {{cpan My::Module}}
10 - MojoMojo::Formatter::YouTube - handles {{youtube <url>}}
10 - MojoMojo::Formatter::Wiki - handles [[wikilinks]]
10 - MojoMojo::Formatter::Pod - handles {{pod}} ... {{end}} blocks
14 - MojoMojo::Formater::IRCLog - handles {{irc}} ... {{end}} blocks
14 - MojoMojo::Formatter::SyntaxHighlight - Performs syntax highlighting on code blocks
15 - Main formatter (MojoMojo::Formatter::Markdown or MojoMojo::Formatter::Textile)
16 - MojoMojo::Formatter::Defang - removes harmful HTML and XSS
91 - MojoMojo::Formatter::Comment - handles {{comments}}, inserts a comment box
95 - MojoMojo::Formatter::TOC - replaces {{toc}} with a table of contents

Note that if your formatter expects HTML text, it should run after the main formatter.

If you want your formatter to do something, you also need to override "format_content". It gets passed its classname, a scalar ref to the content, and the context object. It should return the scalar ref.

Override this method if your formatter is a primary one (equivalent to Markdown or Textile). It gets passed the same arguments as "format_content". Also make sure to update "Site settings" (/.admin).

Note that the main formatter runs at 15.

Return true if a formatter module is loaded.

    gen_re(qr/irc/)

Returns a regular expression for the given tag between matching double braces.

MojoMojo, MojoMojo::Formatter::Textile, MojoMojo::Formatter::Markdown

Marcus Ramberg <mramberg@cpan.org>

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
2016-12-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.