Skip to content

Commit 0ace806

Browse files
author
roadiz-ci
committed
chore: bumped
1 parent bd2d19c commit 0ace806

6 files changed

Lines changed: 25 additions & 49 deletions

File tree

.github/workflows/run-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Static analysis and code style
1+
name: Unit tests, static analysis and code style
22

33
on:
44
push:
@@ -15,11 +15,11 @@ on:
1515
- ready_for_review
1616

1717
jobs:
18-
static-analysis-tests:
18+
run-tests:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
php-version: ['8.3', '8.4', '8.5']
22+
php-version: ['8.2', '8.3']
2323
steps:
2424
- uses: shivammathur/setup-php@v2
2525
with:

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright © 2025 Ambroise Maupate
3+
Copyright © 2024 Ambroise Maupate
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"description": "Markdown services and Twig extension for Roadiz",
44
"type": "library",
55
"require": {
6-
"php": ">=8.3",
6+
"php": ">=8.2",
77
"doctrine/collections": ">=1.6",
88
"league/commonmark": "^2.2.0",
9-
"symfony/stopwatch": "7.4.*",
10-
"twig/twig": "^3.21"
9+
"symfony/stopwatch": "6.4.*",
10+
"twig/twig": "^3.16"
1111
},
1212
"require-dev": {
13-
"phpstan/phpstan": "^2.1.36",
13+
"phpstan/phpstan": "^1.5.3",
1414
"phpstan/phpdoc-parser": "<2"
1515
},
1616
"license": "MIT",
@@ -29,8 +29,8 @@
2929
},
3030
"extra": {
3131
"branch-alias": {
32-
"dev-master": "2.7.x-dev",
33-
"dev-develop": "2.8.x-dev"
32+
"dev-master": "2.5.x-dev",
33+
"dev-develop": "2.6.x-dev"
3434
}
3535
}
3636
}

src/CommonMark.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,34 @@ public function __construct(
1313
private MarkdownConverter $textConverter,
1414
private MarkdownConverter $textExtraConverter,
1515
private MarkdownConverter $lineConverter,
16-
private MarkdownConverter $textHtmlConverter,
17-
private MarkdownConverter $textExtraHtmlConverter,
1816
private ?Stopwatch $stopwatch = null,
1917
) {
2018
}
2119

22-
#[\Override]
23-
public function text(?string $markdown = null, bool $allowHtml = false): string
20+
public function text(?string $markdown = null): string
2421
{
2522
if (null === $markdown) {
2623
return '';
2724
}
2825
$this->stopwatch?->start(CommonMark::class.'::text');
29-
$converter = $allowHtml ? $this->textHtmlConverter : $this->textConverter;
30-
$html = $converter->convert($markdown)->getContent();
26+
$html = $this->textConverter->convert($markdown)->getContent();
3127
$this->stopwatch?->stop(CommonMark::class.'::text');
3228

3329
return $html;
3430
}
3531

36-
#[\Override]
37-
public function textExtra(?string $markdown = null, bool $allowHtml = false): string
32+
public function textExtra(?string $markdown = null): string
3833
{
3934
if (null === $markdown) {
4035
return '';
4136
}
4237
$this->stopwatch?->start(CommonMark::class.'::textExtra');
43-
$converter = $allowHtml ? $this->textExtraHtmlConverter : $this->textExtraConverter;
44-
$html = $converter->convert($markdown)->getContent();
38+
$html = $this->textExtraConverter->convert($markdown)->getContent();
4539
$this->stopwatch?->stop(CommonMark::class.'::textExtra');
4640

4741
return $html;
4842
}
4943

50-
#[\Override]
5144
public function line(?string $markdown = null): string
5245
{
5346
if (null === $markdown) {

src/MarkdownInterface.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@ interface MarkdownInterface
88
{
99
/**
1010
* Convert Markdown to HTML using standard Markdown syntax.
11-
*
12-
* @param bool $allowHtml Pass true to allow raw HTML (including script/style tags) through
13-
* unchanged. Defaults to false (raw HTML is stripped).
1411
*/
15-
public function text(?string $markdown = null, bool $allowHtml = false): string;
12+
public function text(?string $markdown = null): string;
1613

1714
/**
1815
* Convert Markdown to HTML using standard Markdown Extra syntax.
19-
*
20-
* @param bool $allowHtml Pass true to allow raw HTML (including script/style tags) through
21-
* unchanged. Defaults to false (raw HTML is stripped).
2216
*/
23-
public function textExtra(?string $markdown = null, bool $allowHtml = false): string;
17+
public function textExtra(?string $markdown = null): string;
2418

2519
/**
2620
* Convert Markdown to HTML using only inline HTML elements.

src/Twig/MarkdownExtension.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,24 @@ public function __construct(private readonly MarkdownInterface $markdown)
1414
{
1515
}
1616

17-
#[\Override]
1817
public function getFilters(): array
1918
{
2019
return [
21-
new TwigFilter('markdown', $this->markdown(...), ['is_safe' => ['html']]),
22-
new TwigFilter('inlineMarkdown', $this->inlineMarkdown(...), ['is_safe' => ['html']]),
23-
new TwigFilter('inline_markdown', $this->inlineMarkdown(...), ['is_safe' => ['html']]),
24-
new TwigFilter('markdownExtra', $this->markdownExtra(...), ['is_safe' => ['html']]),
25-
new TwigFilter('markdown_extra', $this->markdownExtra(...), ['is_safe' => ['html']]),
20+
new TwigFilter('markdown', [$this, 'markdown'], ['is_safe' => ['html']]),
21+
new TwigFilter('inlineMarkdown', [$this, 'inlineMarkdown'], ['is_safe' => ['html']]),
22+
new TwigFilter('inline_markdown', [$this, 'inlineMarkdown'], ['is_safe' => ['html']]),
23+
new TwigFilter('markdownExtra', [$this, 'markdownExtra'], ['is_safe' => ['html']]),
24+
new TwigFilter('markdown_extra', [$this, 'markdownExtra'], ['is_safe' => ['html']]),
2625
];
2726
}
2827

29-
/**
30-
* @param bool $allowHtml Set to true to allow raw HTML (including script/style tags) through
31-
* unchanged. Defaults to false — raw HTML is stripped.
32-
* Usage: {{ content|markdown(true) }}
33-
*/
34-
public function markdown(?string $input, bool $allowHtml = false): string
28+
public function markdown(?string $input): string
3529
{
3630
if (null === $input) {
3731
return '';
3832
}
3933

40-
return $this->markdown->text($input, $allowHtml);
34+
return $this->markdown->text($input);
4135
}
4236

4337
public function inlineMarkdown(?string $input): string
@@ -49,17 +43,12 @@ public function inlineMarkdown(?string $input): string
4943
return $this->markdown->line($input);
5044
}
5145

52-
/**
53-
* @param bool $allowHtml Set to true to allow raw HTML (including script/style tags) through
54-
* unchanged. Defaults to false — raw HTML is stripped.
55-
* Usage: {{ content|markdownExtra(true) }}
56-
*/
57-
public function markdownExtra(?string $input, bool $allowHtml = false): string
46+
public function markdownExtra(?string $input): string
5847
{
5948
if (null === $input) {
6049
return '';
6150
}
6251

63-
return $this->markdown->textExtra($input, $allowHtml);
52+
return $this->markdown->textExtra($input);
6453
}
6554
}

0 commit comments

Comments
 (0)