jfcere / ngx-markdown

Angular markdown component/directive/pipe/service to parse static, dynamic or remote content to HTML with syntax highlight and more...
https://jfcere.github.io/ngx-markdown
MIT License
1.06k stars 182 forks source link

Blank lines not preserved #519

Closed Crystal-Spider closed 4 months ago

Crystal-Spider commented 4 months ago

My markdown is as follows:

Line 1

Line 2

Line 3

However it becomes:

<markdown _ngcontent-ng-c456785852="" ngpreservewhitespaces="" ng-reflect-data="Line 1

Line 2

Line 3"><p>Line 1</p>
<p>Line 2</p>
<p>Line 3</p>
</markdown>

And thus it renders as: Line 1 Line 2 Line 3

Rather than: Line 1

Line 2

Line 3

I have this configuration in my appConfig (I'm using standalone components):

provideMarkdown({
  markedOptions: {
    provide: MARKED_OPTIONS,
    useValue: {
      gfm: true,
      breaks: false
    }
  }
})

And I added both the ngPreserveWhitespaces directive to the markdown component, and I set the preserveWhitespaces option in my component to true.

jfcere commented 4 months ago

Hi @Crystal-Spider,

This is intended according to the CommonMark blank lines specification, so it works as expected, as demonstrated on the marked demo.

image

Crystal-Spider commented 4 months ago

Hi! Thank you for the explanation!

You're right, I forgot I had removed margins from all elements, and thus ps too, that's why different paragraphs didn't have any space in between.