Skip to content

Commit

Permalink
Return HtmlStrings with html content
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiandedeyne committed May 31, 2018
1 parent fc87635 commit 7ac3498
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ContentParsers/MarkdownParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Spatie\Sheets\ContentParsers;

use Illuminate\Support\HtmlString;
use League\CommonMark\CommonMarkConverter;
use Spatie\Sheets\ContentParser;

Expand All @@ -17,8 +18,10 @@ public function __construct(CommonMarkConverter $commonMarkConverter)

public function parse(string $contents): array
{
$htmlContents = $this->commonMarkConverter->convertToHtml($contents);

return [
'contents' => $this->commonMarkConverter->convertToHtml($contents),
'contents' => new HtmlString($htmlContents),
];
}
}
5 changes: 4 additions & 1 deletion src/ContentParsers/MarkdownWithFrontMatterParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Spatie\Sheets\ContentParsers;

use Illuminate\Support\HtmlString;
use League\CommonMark\CommonMarkConverter;
use Spatie\Sheets\ContentParser;
use Spatie\YamlFrontMatter\YamlFrontMatter;
Expand All @@ -20,9 +21,11 @@ public function parse(string $contents): array
{
$document = YamlFrontMatter::parse($contents);

$htmlContents = $this->commonMarkConverter->convertToHtml($document->body());

return array_merge(
$document->matter(),
['contents' => $this->commonMarkConverter->convertToHtml($document->body())]
['contents' => new HtmlString($htmlContents)]
);
}
}

0 comments on commit 7ac3498

Please sign in to comment.