fix several rendering issues in markdown (#3588)
- fix double escaping of html entities: " instead of " - fix table is missing css class "table" - fix quotes are not rendered
This commit is contained in:
@@ -63,7 +63,7 @@ final class MarkdownExtension implements RuntimeExtensionInterface
|
|||||||
if ($this->isMarkdownEnabled()) {
|
if ($this->isMarkdownEnabled()) {
|
||||||
$content = $this->markdown->toHtml($content);
|
$content = $this->markdown->toHtml($content);
|
||||||
} elseif ($fullLength) {
|
} elseif ($fullLength) {
|
||||||
$content = '<p>' . nl2br($content) . '</p>';
|
$content = '<p>' . nl2br(htmlspecialchars($content)) . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
@@ -115,7 +115,7 @@ final class MarkdownExtension implements RuntimeExtensionInterface
|
|||||||
return $this->markdown->toHtml($content);
|
return $this->markdown->toHtml($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nl2br($content);
|
return nl2br(htmlspecialchars($content));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ class RuntimeExtensions extends AbstractExtension
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFilter('md2html', [MarkdownExtension::class, 'markdownToHtml'], ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
new TwigFilter('md2html', [MarkdownExtension::class, 'markdownToHtml'], ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
||||||
new TwigFilter('desc2html', [MarkdownExtension::class, 'timesheetContent'], ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
new TwigFilter('desc2html', [MarkdownExtension::class, 'timesheetContent'], ['is_safe' => ['html']]),
|
||||||
new TwigFilter('comment2html', [MarkdownExtension::class, 'commentContent'], ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
new TwigFilter('comment2html', [MarkdownExtension::class, 'commentContent'], ['is_safe' => ['html']]),
|
||||||
new TwigFilter('comment1line', [MarkdownExtension::class, 'commentOneLiner'], ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
new TwigFilter('comment1line', [MarkdownExtension::class, 'commentOneLiner'], ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
||||||
new TwigFilter('colorize', [ThemeExtension::class, 'colorize']),
|
new TwigFilter('colorize', [ThemeExtension::class, 'colorize']),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class ParsedownExtension extends \Parsedown
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwritten to prevent # to show up as headings for two reasons:
|
* Overwritten to prevent # to show up as headings for two reasons:
|
||||||
* - Hashes are often used to cross link issues in other systems
|
* - Hashes are often used to cross-link issues in other systems
|
||||||
* - Headings should not occur in time record listings
|
* - Headings should not occur in time record listings
|
||||||
*/
|
*/
|
||||||
protected $BlockTypes = [
|
protected $BlockTypes = [
|
||||||
@@ -146,4 +146,17 @@ class ParsedownExtension extends \Parsedown
|
|||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function blockTable($Line, array $Block = null)
|
||||||
|
{
|
||||||
|
$Block = parent::blockTable($Line, $Block);
|
||||||
|
|
||||||
|
if (\is_null($Block)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$Block['element']['attributes']['class'] = 'table';
|
||||||
|
|
||||||
|
return $Block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,12 +80,10 @@ class RuntimeExtensionsTest extends TestCase
|
|||||||
$found_md2html = true;
|
$found_md2html = true;
|
||||||
break;
|
break;
|
||||||
case 'desc2html':
|
case 'desc2html':
|
||||||
self::assertEquals('html', $filters[1]->getPreEscape());
|
|
||||||
self::assertEquals(['html'], $filters[1]->getSafe(new Node()));
|
self::assertEquals(['html'], $filters[1]->getSafe(new Node()));
|
||||||
$found_desc2html = true;
|
$found_desc2html = true;
|
||||||
break;
|
break;
|
||||||
case 'comment2html':
|
case 'comment2html':
|
||||||
self::assertEquals('html', $filters[2]->getPreEscape());
|
|
||||||
self::assertEquals(['html'], $filters[2]->getSafe(new Node()));
|
self::assertEquals(['html'], $filters[2]->getSafe(new Node()));
|
||||||
$found_comment2html = true;
|
$found_comment2html = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user