markdown-to-jsx icon indicating copy to clipboard operation
markdown-to-jsx copied to clipboard

Markdown line that starts with <u> html tag has inconsistent behavior

Open MikeBeasterfeld opened this issue 9 months ago • 0 comments

There is some behavior that I wouldn't expect when working with markdown with html tags. I added the below tests to index.component.spec.tsx

it('test for markdown paragraph and html tags', () => {
  render(
    <Markdown
      options={{
        overrides: {
          p: {
            component: 'p',
          },
        },
      }}
    >
      {'Other text <u>Underline</u>\n'}
    </Markdown>
  )

  expect(root.innerHTML).toMatchInlineSnapshot(`
  <p>
    Other text
    <u>
      Underline
    </u>
  </p>
  `)
})

it('test for markdown paragraph and start line with html tag', () => {
  render(
    <Markdown
      options={{
        overrides: {
          p: {
            component: 'p',
          },
        },
      }}
    >
      {'<u>Underline</u> Other text\n'}
    </Markdown>
  )

  expect(root.innerHTML).toMatchInlineSnapshot(`
  <p>
    <u>
      Underline
    </u>
    Other text
  </p>
  `)
})

The first test passes as expected. However the second test generates the following:

<div>
  <u>
    Underline
  </u>
  Other text
</div>

MikeBeasterfeld avatar Oct 26 '23 18:10 MikeBeasterfeld