Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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:
- Enable the module.
- Add composer package
league/commonmark
to the project. - Add an text filter with markdown filter with CommonMark parser.
- Try to save a new node with the text filter.
- You can see the exception occurs.
Proposed resolution
Change the line
$converter = new League\CommonMark\CommonMarkConverter();
to
$converter = new CommonMarkConverter();
Comment | File | Size | Author |
---|---|---|---|
#2 | markdown-fix_commonmark_exception-2882688-2.patch | 564 bytes | hgoto |
Comments
Comment #2
hgoto CreditAttribution: hgoto as a volunteer commentedHere is a simple patch which fixes the problem.
Comment #3
frjo CreditAttribution: frjo commentedComment #5
frjo CreditAttribution: frjo commentedCommitted to 8-dev. Thanks for the report and solution! Will do a new release as well.
Comment #6
hgoto CreditAttribution: hgoto as a volunteer commentedThank you!