Skip to content

Commit 4024381

Browse files
committed
fix: corrected usage of Markdown class
1 parent 4c45242 commit 4024381

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

.docker/php-fpm/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ RUN set -ex \
5858
&& rm -rf /var/lib/apt/lists/*
5959

6060
#=== Install xdebug PHP dependencies ===
61-
#RUN pecl install xdebug-3.4.1 \
62-
#&& docker-php-ext-enable xdebug
61+
RUN pecl install xdebug-3.4.2 \
62+
&& docker-php-ext-enable xdebug
6363

6464
#=== php default ===
6565
ENV PMF_TIMEZONE="Europe/Berlin" \

phpmyfaq/src/phpMyFAQ/Helper/FaqHelper.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717

1818
namespace phpMyFAQ\Helper;
1919

20-
use League\CommonMark\CommonMarkConverter;
20+
use League\CommonMark\Environment\Environment;
2121
use League\CommonMark\Exception\CommonMarkException;
22+
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
23+
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
24+
use League\CommonMark\MarkdownConverter;
2225
use phpMyFAQ\Category;
2326
use phpMyFAQ\Configuration;
2427
use phpMyFAQ\Entity\FaqEntity;
@@ -103,11 +106,18 @@ public function renderChangeLanguageSelector(Faq $faq, int $categoryId): string
103106
public function renderAnswerPreview(string $answer, int $wordCount): string
104107
{
105108
if ($this->configuration->get('main.enableMarkdownEditor')) {
106-
$markdownConverter = new CommonMarkConverter([
109+
$config = [
107110
'html_input' => 'strip',
108111
'allow_unsafe_links' => false,
109-
]);
110-
$cleanedAnswer = $markdownConverter->convert($answer)->getContent();
112+
];
113+
114+
$environment = new Environment($config);
115+
$environment->addExtension(new CommonMarkCoreExtension());
116+
$environment->addExtension(new GithubFlavoredMarkdownExtension());
117+
118+
$converter = new MarkdownConverter($environment);
119+
120+
$cleanedAnswer = $converter->convert($answer)->getContent();
111121
return Utils::chopString(strip_tags($cleanedAnswer), $wordCount);
112122
}
113123

phpmyfaq/src/phpMyFAQ/Helper/SearchHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public function getSearchResult(SearchResultSet $searchResultSet, int $currentPa
177177
$counter = 0;
178178
$displayedCounter = 0;
179179
$faqHelper = new FaqHelper($this->configuration);
180+
180181
foreach ($searchResultSet->getResultSet() as $resultSet) {
181182
$result = new stdClass();
182183

0 commit comments

Comments
 (0)