Skip to content

Commit 295e561

Browse files
authored
Merge pull request #1 from DevToolsCZ/main
Success Fix ready for new Version
2 parents 9ba68aa + 629940e commit 295e561

File tree

4 files changed

+14
-51
lines changed

4 files changed

+14
-51
lines changed

src/Extra/Parsedown.php

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

1818
class Parsedown
1919
{
20-
# ~
21-
2220
const version = '1.8.0-beta-7';
2321

24-
# ~
25-
2622
function text($text)
2723
{
2824
$Elements = $this->textElements($text);

src/LatteMarkdown.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
use Devtoolcz\Markdown\Extra\Parsedown;
88
use Latte\Runtime\FilterInfo;
9-
use ParseAdapter;
9+
use Nette\Utils\Html;
1010

1111
class LatteMarkdown
1212
{
13-
/** @var ParseAdapter */
14-
private $parseAdapter;
13+
/** @var Parsedown */
14+
private $parsedown;
1515

16-
public function __construct(ParseAdapter $parseAdapter) {
17-
$this->parseAdapter = $parseAdapter;
16+
public function __construct(Parsedown $parsedown) {
17+
$this->parsedown = $parsedown;
1818
}
1919

20-
public function apply(FilterInfo $filterInfo, $text)
20+
public function apply(FilterInfo $info, $text)
2121
{
22-
$this->parseAdapter->process($text);
22+
$html = new Html();
23+
return $html::el()->setHtml($this->parsedown->parse($text));
2324
}
24-
2525
}

src/Nette/DI/MarkdownExtension.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Devtoolcz\Markdown\Nette\DI;
66

7+
use Devtoolcz\Markdown\Extra\Parsedown;
78
use Devtoolcz\Markdown\LatteMarkdown;
89
use Devtoolcz\Markdown\ParseAdapter;
910
use Nette\Bridges\ApplicationLatte\ILatteFactory;
@@ -27,8 +28,8 @@ public function loadConfiguration(): void
2728
{
2829
$builder = $this->getContainerBuilder();
2930

30-
$builder->addDefinition($this->prefix('parsedown'))
31-
->setFactory(ParseAdapter::class);
31+
$builder->addDefinition($this->prefix('parseDown'))
32+
->setFactory(Parsedown::class);
3233
}
3334

3435
public function beforeCompile()
@@ -39,9 +40,11 @@ public function beforeCompile()
3940
throw new InvalidStateException(sprintf('Service which implements %s not found.', ILatteFactory::class));
4041

4142
$config = (array) $this->config;
43+
4244
$latte = $builder->getDefinitionByType(ILatteFactory::class);
4345
assert($latte instanceof FactoryDefinition);
44-
$latte->getResultDefinition()->addSetup('addFilter', $config['syntax_helper'], [new Statement(LatteMarkdown::class)], '');
46+
47+
$latte->getResultDefinition()->addSetup('addFilter', [$config['syntax_helper'], [new Statement(LatteMarkdown::class), 'apply']]);
4548
}
4649

4750
}

src/ParseAdapter.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)