Skip to content

Commit 8509872

Browse files
committed
fixed escaping and filter order
1 parent 28e190b commit 8509872

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/LatexFilterExtension.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ class LatexFilterExtension extends \Twig\Extension\AbstractExtension
99
public function getFilters(): array
1010
{
1111
return [
12-
new TwigFilter('nl2tex', [$this, 'nl2tex']),
12+
new TwigFilter('nl2tex', [$this, 'nl2tex'], ['pre_escape' => 'tex', 'is_safe' => true]),
1313
];
1414
}
1515

16-
public function nl2tex(?string $in): string
16+
public function nl2tex(string $in): string
1717
{
18-
if ($in === null) {
19-
return '';
20-
}
2118
return str_replace(PHP_EOL, '\\\\', $in);
2219
}
2320
}

0 commit comments

Comments
 (0)