zWingz / remark-container

remark plugin for custom container
MIT License
9 stars 1 forks source link

multi-line link breaks when using remark-container #3

Closed pimlie closed 5 years ago

pimlie commented 5 years ago

Thanks for this plugin!

See the following test:

  it('test multi-line link', () => {
    const str = `
[Link on
two lines](https://example.com)
`
    const $ = getHTML(str)
    const container = $(`a`)

    expect(container).toHaveLength(1)
    expect(container.text()).toEqual('Link on two lines')
  })

This test fails as both lines end-up being wrapped into paragraphs. The multi-line link appears to be valid markdown: https://spec.commonmark.org/dingus/?text=%5BLink%20on%0Atwo%20lines%5D(https%3A%2F%2Fexample.com)&smart=1

The issue seems caused by customContainer being inserted after newline in blockMethods. If you'd just unshift blockMethods with customContainer the above test succeeds.

Ofc that will break the test multi content test as that expects both lines to be wrapped in individual paragraphs while after this change there is only one paragraph containing both lines.

Not sure if you think is a defect or not. If you think so I could prepare a PR if you want (but feel free to fix it yourself as thats probably quicker ;)