- <?php
-
-
- function markdown_help($path = 'admin/help#markdown', $arg) {
- switch ($path) {
- case 'admin/help#markdown':
- return t('<p>The Markdown filter allows you to enter content using <a href="http://daringfireball.net/projects/markdown">Markdown</a>, a simple plain-text syntax that is transformed into valid XHTML.</p>');
- 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:<ul>
- <li>Two or more spaces at a line\'s end = Line break</li>
- <li>Double returns = Paragraph</li>
- <li>*Single asterisks* or _single underscores_ = <em>Emphasis</em></li>
- <li>**Double** or __double__ = <strong>Strong</strong></li>
- <li>This is [a link](http://the.link.example.com "The optional title text")</li>
- </ul>For complete details on the Markdown syntax, see the <a href="http://daringfireball.net/projects/markdown/syntax">Markdown documentation</a> and <a href="http://michelf.com/projects/php-markdown/extra/">Markdown Extra documentation</a> for tables, footnotes, and more.');
- }
- else {
- return t('You can use <a href="@filter_tips">Markdown syntax</a> to format and style the text. Also see <a href="@markdown_extra">Markdown Extra</a> for tables, footnotes, and more.', array('@filter_tips' => url('filter/tips'), '@markdown_extra' => 'http://michelf.com/projects/php-markdown/extra/'));
- }
- }
-
-
- * Provides content for the markdown help block.
- */
- function _markdown_help_block(){
- return '<pre>'. 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();") .'</pre>';
- }
-
- * 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: <a href="http://www.michelf.com/projects/php-markdown/">'. MARKDOWN_VERSION .'</a>',
- 'Markdown Extra Version: <a href="http://www.michelf.com/projects/php-markdown/">'. MARKDOWNEXTRA_VERSION .'</a>',
- );
- $form['markdown_wrapper']['markdown_status'] = array(
- '#title' => t('Versions'),
- '#type' => 'item',
- '#value' => theme('item_list', $links),
- );
- return $form;
- }
-