Not a developer? Go to


Text Filters

One of the very first Movable Type plugins ever created was a simple text filter. Text filters are used to transform the plain text input by a user into the entry and page editing interfaces, or through a commenting form into some other format. This first plugin called “Convert Line Breaks” made it possible for someone to enter the follow text into Movable Type:

Last night I had a great time with some friends.

We went to a restaurant and then a movie.

To the following:

Last night I had a great time with some friends.<br />
<br />
We went to a restaurant and then a movie.

The added break tags (<br />) helps preserve the formatting of the original text without requiring the user to know HTML.

Movable Type ships with several built in text filters, including:

  • Markdown
  • Textile
  • SmartyPants
  • Convert line breaks

Each of these text filters converts the text written in an alternate markup into the corresponding HTML syntax. However, there are many other possible uses for a text transformation plugin including one that may auto-correct spelling, automatically link certain words to specific websites, etc.

Note: The text entered by the user is stored in the database in its original form. The transformation occurs at the time the entry is published only.

To register a text filter, use the following code sample:

name: Example Plugin for Movable Type
id: Example
description: This plugin is an example plugin for Movable Type.
version: 1.0
        label: My Text Transform
        handler: $Example::Example::Plugin::mytransform
        condition: $Example::Example::Plugin::mytransform_when

There are a number of properties for a text filter that can used when registering the text filter with Movable Type. These options are:

  • label - the display name of the text filter as it will appear in the Movable Type user interface

  • handler - a reference to a subroutine responsible for handling the transformation

  • condition - in the event that the text filter should only be applied under specific conditions, one can identify a reference to a subroutine that will return true if the filter can be applied, and false otherwise.