Skip to content

Fix text missing after HTML tags#5320

Merged
compulim merged 10 commits into
microsoft:mainfrom
compulim:fix-markdown-after-html
Oct 7, 2024
Merged

Fix text missing after HTML tags#5320
compulim merged 10 commits into
microsoft:mainfrom
compulim:fix-markdown-after-html

Conversation

@compulim
Copy link
Copy Markdown
Contributor

@compulim compulim commented Oct 7, 2024

Fixes #5319.

Changelog Entry

Fixed

Description

Our HTML parsing and serialization logic only handle .children but not .childNodes. Thus, it is omitting text nodes.

When dealing with certain types of Markdown, the text may not be wrapped in <p>. For example,

Line 1

<br />
Line 2

Will be converted to HTML and "Line 2" is not wrapped in <p> and is a text node.

<p>Line 1</p><br />Line 2

Specific Changes

  • Updates serializeDocumentIntoString and useRenderMarkdownAsHTML to handle text nodes
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim compulim marked this pull request as ready for review October 7, 2024 21:11
OEvgeny
OEvgeny previously approved these changes Oct 7, 2024
Comment thread packages/component/src/Utils/parseDocumentFragmentFromString.ts
OEvgeny
OEvgeny previously approved these changes Oct 7, 2024
@compulim compulim merged commit 1d59ded into microsoft:main Oct 7, 2024
@compulim compulim deleted the fix-markdown-after-html branch October 7, 2024 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some Markdown after HTML tags are not rendered

2 participants