Skip to content

Commit af2ed52

Browse files
committed
feat: Refactor MarkdownConverter to use getter methods for configs and extensions
1 parent 4a09381 commit af2ed52

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Fields/Converters/MarkdownConverter.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,36 @@ public function setExtensions(array $extensions, bool $merge = true): static
6363
return $this;
6464
}
6565

66+
public function getConfigs(): array
67+
{
68+
return $this->mdConfigs;
69+
}
70+
71+
public function getExtensions(): array
72+
{
73+
$extensions = $this->mdExtensions;
74+
75+
$defaultExtensions = [
76+
app(\League\CommonMark\Extension\Attributes\AttributesExtension::class),
77+
];
78+
79+
foreach ($defaultExtensions as $extension) {
80+
if (! in_array($extension, $extensions, true)) {
81+
$extensions[] = $extension;
82+
}
83+
}
84+
85+
return $extensions;
86+
}
87+
6688
private function convertMarkdown($value)
6789
{
6890
try {
6991
if (! is_string($value)) {
7092
return $value;
7193
}
7294

73-
$value = str($value)->markdown($this->mdConfigs, $this->mdExtensions)->toHtmlString();
95+
$value = str($value)->markdown($this->getConfigs(), $this->getExtensions())->toHtmlString();
7496

7597
return $value;
7698

0 commit comments

Comments
 (0)