File tree 2 files changed +45
-10
lines changed
2 files changed +45
-10
lines changed Original file line number Diff line number Diff line change @@ -44,11 +44,15 @@ public function __construct(string $content = '')
44
44
/**
45
45
* @return array<mixed> [description]
46
46
*/
47
- public function frontMatter (): array
47
+ public function frontMatter (string $ content = '' ): array
48
48
{
49
+ if (strlen ($ content ) === 0 ) {
50
+ $ content = $ this ->content ;
51
+ }
52
+
49
53
$ frontMatterExtension = new FrontMatterExtension ();
50
54
return $ frontMatterExtension ->getFrontMatterParser ()->parse (
51
- $ this -> content . "\n"
55
+ $ content . "\n"
52
56
)->getFrontMatter ();
53
57
}
54
58
@@ -77,14 +81,6 @@ public function convertToHtml(string $content = ''): RenderedContentInterface
77
81
return $ converter ->convertToHtml ($ this ->content ());
78
82
}
79
83
80
- /**
81
- * @deprecated Use `convert()` instead.
82
- */
83
- public function convertedContent (string $ content = '' ): string
84
- {
85
- return $ this ->convert ($ content );
86
- }
87
-
88
84
public function convert (string $ content = '' ): string
89
85
{
90
86
$ html = $ this ->convertToHtml ($ content )->getContent ();
@@ -106,6 +102,14 @@ public function __toString(): string
106
102
return $ this ->convert ();
107
103
}
108
104
105
+ /**
106
+ * @deprecated Use `convert()` instead.
107
+ */
108
+ public function convertedContent (string $ content = '' ): string
109
+ {
110
+ return $ this ->convert ($ content );
111
+ }
112
+
109
113
/**
110
114
* @return array<mixed> [description]
111
115
*/
Original file line number Diff line number Diff line change 2
2
3
3
use Eightfold \Markdown \Markdown ;
4
4
5
+ test ('Markdown is reusable ' , function () {
6
+ $ markdownConverter = Markdown::create ()->config ([
7
+ 'html_input ' => 'allow ' ,
8
+ 'allow_unsafe_links ' => false
9
+ ])->minified ();
10
+
11
+ expect (
12
+ $ markdownConverter ->convert ()
13
+ )->toBe ('' );
14
+
15
+ expect (
16
+ $ markdownConverter ->convert ('Hello, World! ' )
17
+ )->toBe (<<<html
18
+ <p>Hello, World!</p>
19
+ html
20
+ );
21
+
22
+ expect (
23
+ $ markdownConverter ->frontMatter (<<<md
24
+ ---
25
+ title: Some title
26
+ icon: /path/to/icon alt text
27
+ ---
28
+ md
29
+ )
30
+ )->toBe ([
31
+ 'title ' => 'Some title ' ,
32
+ 'icon ' => '/path/to/icon alt text '
33
+ ]);
34
+ });
35
+
5
36
test ('Markdown has multiple ways to approach rendering content ' , function () {
6
37
expect (
7
38
(string ) Markdown::create ('# Shortest form ' )
You can’t perform that action at this time.
0 commit comments