You are here

markdown.module in Markdown 8

Provides a Markdown input filter.

File

markdown.module
View source
<?php

/**
 * @file
 * Provides a Markdown input filter.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function markdown_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.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 HTML.</p>');
  }
}

/**
 * Implements hook_libraries_info().
 */
function markdown_libraries_info() {
  $libraries['php-markdown'] = [
    'name' => 'PHP Markdown Lib',
    'vendor url' => 'http://michelf.ca/projects/php-markdown/',
    'download url' => 'https://github.com/michelf/php-markdown/archive/lib.zip',
    'path' => 'Michelf',
    'version arguments' => [
      'file' => 'Readme.md',
      'pattern' => '@(?i:PHP Markdown Lib) ([0-9\\.]+)@',
      'lines' => 5,
    ],
    'files' => [
      'php' => [
        'Markdown.inc.php',
      ],
    ],
    'variants' => [
      'markdown' => [
        'files' => [
          'php' => [
            'Markdown.inc.php',
          ],
        ],
      ],
      'markdown-extra' => [
        'files' => [
          'php' => [
            'MarkdownExtra.inc.php',
          ],
        ],
      ],
    ],
  ];
  return $libraries;
}

/**
 * Implements hook_migration_plugins_alter().
 */
function markdown_migration_plugins_alter(array &$migrations) {
  if (isset($migrations['d7_filter_format'])) {
    $migration =& $migrations['d7_filter_format'];

    // Add mapping from filter_markdown to markdown for D7 migratins.
    $migration['process']['filters']['process']['id']['map']['filter_markdown'] = 'markdown';
  }
}