Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure isBlank checks for significant elements within the given node #326

Merged
merged 1 commit into from
May 12, 2020

Conversation

domchristie
Copy link
Collaborator

isBlank currently checks:

  • if the element is meaningful i.e. a 'A', 'TH', 'TD', 'IFRAME', 'SCRIPT', 'AUDIO', 'VIDEO',
  • if the textContent is blank,
  • if the element is a void, and
  • if the element contains a void element

This works for most cases, although fails when the element contains a meaningful element and has a blank textContent e.g.

<figure><iframe src=""></iframe></figure>

(Adapted from: #293)

This pull request checks if the element contains a meaningful element. It also adds 'TABLE', 'THEAD', 'TBODY', 'TFOOT' to the list of meaningful elements.

Fixes #293
Fixes #276
Closes #277
Closes #311

DRY up the is/has functions and always use uppercase to prevent excessive toLowerCase calls
@domchristie domchristie merged commit 5c4d19b into master May 12, 2020
@domchristie domchristie deleted the fix_keeping_elements_with_blank_textcontent branch May 12, 2020 21:55
@jerelmiller
Copy link

First of all, thanks so much for this library! I've found it suppppper useful.

By chance, do you know when this fix might get published? I could really use this. Thanks!

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.

Turndown not recognizing <figure> Add TABLE/THEAD/TBODY/TR as element to not consider blank
2 participants