larecipe icon indicating copy to clipboard operation
larecipe copied to clipboard

Cannot compile markdown with inside html

Open osuagwu opened this issue 3 years ago • 4 comments

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?

osuagwu avatar Sep 11 '20 23:09 osuagwu

No ending </div> tag?

WillGoldstein avatar Sep 12 '20 00:09 WillGoldstein

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);
    }

osuagwu avatar Sep 12 '20 00:09 osuagwu

Cool, can you send a screenshot of the differences that creates?

WillGoldstein avatar Sep 12 '20 01:09 WillGoldstein

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

osuagwu avatar Sep 12 '20 10:09 osuagwu