Elephant418 / Markdownify

The HTML to Markdown converter for PHP
MIT License
192 stars 41 forks source link

<br /> two spaces added before line break #45

Open francoisjacquet opened 1 year ago

francoisjacquet commented 1 year ago

Hello,

I am wondering why Markdownify is adding two spaces ` before the\nline break when converting
` tags?

https://github.com/Elephant418/Markdownify/blob/master/src/Converter.php#L1056

    /**
     * handle <br /> tags
     *
     * @param void
     * @return void
     */
    protected function handleTag_br()
    {
        $this->out("  \n" . $this->indent, true);
        $this->parser->html = ltrim($this->parser->html);
    }

Is it safe remove them? (Did some tests and did not have any error)

       $this->out("\n" . $this->indent, true);
tzi commented 1 year ago

Hi @francoisjacquet 👋

It's depend of your converter configurationn, but usually in Markdown:

It's explicit in the specification here https://www.markdownguide.org/basic-syntax/#line-breaks

francoisjacquet commented 1 year ago

Thank you for your answer.

I believe this works within RosarioSIS because of the following configurations: Parsedown

$Parsedown->setBreaksEnabled( true )

and marked

marked.setOptions({ breaks: true })