Knowledgebase

How to add and edit text formats in Drupal

Text formats use filters to control the output of text (nodes, comments, etc.) on the frontend of your Drupal site. They also limit the actions that users can perform when creating texts. Drupal comes prepackaged with three default text formats: plain text, filtered HTML, and full HTML. The things that can be done when using a particular text format depend on the filters that are enabled for that format.

To edit the existing text formats and to add new ones, log in to the admin panel of your Drupal, click on the Configuration tab in the top navigation bar and on the page that opens click on Text formats. On the next page there's a table with the existing formats. To edit any of them click on its edit button in the table; you can also disable them by clicking on the disable button. To add a new text format click on the Add text format button that's above the top left corner of the table. In both cases the settings that can be configured and edited are the same.

First, you can specify the name of the text format by typing it in the corresponding field. Under it there are some checkboxes. Each one corresponds to one of the existing user roles. Marking a checkbox will make the text format available to users from that user role. Below the user roles are the filters that can be enabled. To enable a filter just mark its checkbox; to disable it, unmark the checkbox. There are several default filters that come prepackaged with Drupal: for limiting the allowed HTML tags, for displaying HTML tags as plain text (disabling HTML), for converting line breaks into HTML (an essential filter for preserving the structure of texts), for converting URLs into links, and for correcting faulty and chopped off HTML.

The enabled filters will be listed on the same page under the section labeled Filter processing order. This is the order in which the filters will be applied before the text is displayed on the frontend. The order for the default filters that come prepackaged with Drupal is preconfigured. You can reorder them by using the four-arrow buttons in front of their names. The order in which the filters are applied is very important. For example, if the filter for displaying HTML tags as plain text is applied after the ones for converting line breaks into HTML and URLs into links, the line breaks will not be applied and the URLs will not be turned into links (instead, the HTML tags responsible for performing these functions will be displayed as plain text).

Some of the filters have additional settings that can be configured if these filters are enabled. From the default filters the ones that have settings are those for limiting the allowed HTML tags and for converting URLs into links. When they are enabled the settings will be displayed under the section for the filter processing order. Use the buttons on the left to switch between the settings for each filter.

After you're done click on the Save configuration button at the bottom of the page.

Users can choose between the different text formats using the corresponding drop-down menu on the text submission form for nodes, comments, etc.

For screenshots and some more details you can also check out the Drupal text formats tutorial.

Was this answer helpful?

 Print this Article

Also Read