Choosing an Input Filter in Drupal
![]()
Input filters transform text in some way. Every time one of our users authors a story or submits a comment, it is the input filters that are responsible for transforming what the user types into the XHTML that is included on the page.
The default input filter for Drupal is Filtered HTML, which automatically convert line breaks to paragraphs and URLs to clickable links. It also allows for a small subset of HTML tags for additional formatting.
While this is a sensible choice for a default input filter, there are easier ways of authoring content…
Choosing your input format
When it comes to choosing input filters for Drupal, we are faced with a bewildering number of choices. Have a look at http://drupal.org/project/Modules/category/63 — there are over 100 filters/editors for you to choose from!
There is even an input filter (Pirate)
that transform English words and phrases into pirate-speak on
International Talk Like a Pirate Day (September 19th)…
lots of fun, but not very useful. 
Generally speaking, there are four broad ways to author your content:
- WYSIWYG style, using either FCKEditor or TinyMCE
- Forum style, using BBCode + Quicktags
- Wiki style, using PEAR Wiki Filter
- Email style, using Markdown with SmartyPants
Ultimately, the choice comes down to the style that you and your site users are most comfortable with.
WYSIWYG style
When WYSIWYG editors (such as FCKEditor and TinyMCE) are configured properly, they can work very well, especially amongst non-technical users who find comfort in an MS Word-like user interface.
Personally though, I tend to be much less productive using a WYSIWYG editor:
- The page takes longer to load and render, thanks mainly to all that JavaScript on the page.
- I am forced to worry about presentation at the same time that I should be concentrating on content.
- They don’t always do what I want — I often find myself switching to “view source” mode to do anything sufficiently complex. And, of course, the editors like to mangle up my carefully handcrafted XHTML!
Forum style
BBCode (short for Bulletin Board Code) has been around for a long time, and is still commonly used today in many online forums and discussion boards. It is designed to allow the user to format their message using simple tags, while preventing them from breaking the site format with malformed HTML.
Anecdotally, most users tend to rely on toolbars to help them insert BBCode into the textarea, rather than manually key in the BBCode syntax itself. In Drupal, the Quicktags extension provides this functionality by displaying a little toolbar above every textarea.
Wiki style
Wikis are often used to create collaborative websites. To this end, the ease of content editing is a key design goal. A simplfied markup language, sometimes known as “wikitext”, is used to specify the structure and formatting of wiki pages. Unfortunately, the style and syntax of wikitexts can vary greatly among wiki implementations.
Via the PEAR Wiki Filter module, Drupal provides support for the following input formats:
- Mediawiki
- TikiWiki
- DokuWiki
- Creole
There is no need to agonise too much over which wikitext style you go with — they all do pretty much the same job, so just just pick one that you feel comfortable with.
Email style
Now for my favourite input filter of all: Markdown with SmartyPants. As its name suggests - this is really a two-in-one filter:
- Markdown
- Allows you to author content using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML.
- SmartyPants
- Provides smart quotes and other typographic goodies (e.g., converting double-hyphens into en-dash entities; converting three periods into an ellipsis entity)
These two filters combine such that you can author content using a plain text syntax that reads like a text-based email. The simplicity of Markdown with SmartyPants need to be seen to be believed — click here to view the source for this article.
Summing up…
Ultimately, the choice comes down to the style that you and your site users are most comfortable with.
The fact that there isn’t a single input filter that is right for everyone is reflected in the design of Drupal — in the administration pages for input formats (/admin/settings/filters), you can configure which input formats are available to each of your site roles; if a particular role has access to more than one input format, the user is able to choose between the available input formats.
Good luck with it — with so many input filters to choose from, there is something for everybody!