larecipe
larecipe copied to clipboard
Cannot compile markdown with inside html
I was shouting victory until I found that the following does not work:
<div id="intro">
# Introduction
Welcome to the User Manual.
<div>
The presents of the html stops the markdown from working. This does not happen with league/commonmark converter which works quite fine. Also github has no issue compiling the above to markdown why is Larecipe not compiling it?
How to fix?
No ending </div>
tag?
No ending
</div>
tag?
Nope the issue I have now seen is from ParsedownExtra used in \BinaryTorch\LaRecipe\Traits\HasMarkdownParser;.
All works fine by changing:
<?php
namespace BinaryTorch\LaRecipe\Traits;
use ParsedownExtra;
trait HasMarkdownParser
{
/**
* @param $text
* @return null|string|string[]
* @throws \Exception
*/
public function parse($text)
{
return (new ParsedownExtra)->text($text);
}
}
to:
<?php
namespace BinaryTorch\LaRecipe\Traits;
use League\CommonMark\CommonMarkConverter;
trait HasMarkdownParser
{
/**
* @param $text
* @return null|string|string[]
* @throws \Exception
*/
public function parse($text)
{
return (new CommonMarkConverter())->convertToHtml($text);
}
Cool, can you send a screenshot of the differences that creates?
Cool, can you send a screenshot of the differences that creates?
I will try to get you a screen shot but this is super simple to produce: Given
<div id="intro">
# Introduction
Welcome to the User Manual.
</div>
Larecipe does not produce any H1 tag. While Commonmark produces the H1 tag etc. see https://github.com/erusev/parsedown/issues/133