The Markdown filter allows you to enter content using Markdown, a simple plain-text syntax that is transformed into valid XHTML.

'); break; } } /** * Implementation of hook_filter(). */ function markdown_filter($op, $delta = 0, $format = -1, $text = '') { switch ($op) { case 'list': return array(t('Markdown')); case 'description': return t('Allows content to be submitted using Markdown, a simple plain-text syntax that is filtered into valid XHTML.'); case 'settings': return _markdown_settings($format); case 'process': return _markdown_process($text, $format); default: return $text; } } /** * Implementation of hook_block(). * * Provides help for markdown syntax. */ function markdown_block($op = 'list', $delta = 0, $edit = array()) { switch($op) { case 'list': return array('help' => array('info' => t('Markdown filter tips'))); case 'view': switch($delta) { case 'help': return array( 'subject' => t('Markdown filter tips'), 'content' => _markdown_help_block() ); } } } /** * Implementation of hook_filter_tips(). */ function markdown_filter_tips($delta = 0, $format = -1, $long) { if ($long) { return t('Quick Tips:For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.'); } else { return t('You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.', array('@filter_tips' => url('filter/tips'), '@markdown_extra' => 'http://michelf.com/projects/php-markdown/extra/')); } } // == Internal functions ======================================================= /** * Provides content for the markdown help block. */ function _markdown_help_block(){ return '
'. t("
## Header 2 ##
### Header 3 ###
#### Header 4 ####
##### Header 5 #####
(Hashes on right are optional)

Link [Drupal](http://drupal.org)

Inline markup like _italics_,
 **bold**, and `code()`.

> Blockquote. Like email replies
>> And, they can be nested

* Bullet lists are easy too
- Another one
+ Another one

1. A numbered list
2. Which is numbered
3. With periods and a space

And now some code:
    // Code is indented text
    is_easy() to_remember();") .'
'; } /** * Filter process callback. */ function _markdown_process($text, $format) { if (!empty($text)) { include_once drupal_get_path('module', 'markdown') .'/markdown.php'; $text = Markdown($text); } return $text; } /** * Filter settings callback. Just provides a version overview. */ function _markdown_settings($format) { include_once drupal_get_path('module', 'markdown') .'/markdown.php'; $form['markdown_wrapper'] = array( '#type' => 'fieldset', '#title' => t('Markdown'), ); $links = array( 'Markdown PHP Version: '. MARKDOWN_VERSION .'', 'Markdown Extra Version: '. MARKDOWNEXTRA_VERSION .'', ); $form['markdown_wrapper']['markdown_status'] = array( '#title' => t('Versions'), '#type' => 'item', '#value' => theme('item_list', $links), ); return $form; }