Problem/Motivation

The markdown filter doesn't work if CommonMark is selected as the parser.

This problem is caused by the following part:

Markdown.php:


namespace Drupal\markdown\Plugin\Filter;

...

        case 'commonmark':
          $converter = new League\CommonMark\CommonMarkConverter();
          $text = $converter->convertToHtml($text);
          break;

The steps to reproduce:

  1. Enable the module.
  2. Add composer package league/commonmark to the project.
  3. Add an text filter with markdown filter with CommonMark parser.
  4. Try to save a new node with the text filter.
  5. You can see the exception occurs.

Proposed resolution

Change the line

          $converter = new League\CommonMark\CommonMarkConverter();

to

          $converter = new CommonMarkConverter();
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hgoto created an issue. See original summary.

hgoto’s picture

Status: Active » Needs review
FileSize
564 bytes

Here is a simple patch which fixes the problem.

frjo’s picture

Title: Class 'Drupal\markdown\Plugin\Filter\League\CommonMark\CommonMarkConverter' not found » Do not call classes with full path it will result in not found error

  • frjo committed b9225cb on 8.x-1.x
    Issue #2882688 by hgoto: Do not call classes with full path it will...
frjo’s picture

Status: Needs review » Fixed

Committed to 8-dev. Thanks for the report and solution! Will do a new release as well.

hgoto’s picture

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.