Skip to content

Get all of a DOM element's cleaned and standardized text content.

License

Notifications You must be signed in to change notification settings

koalatiapp/extract-dom-content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

extract-dom-content

NPM version of extract-dom-content

Provide a DOM element and get all of its cleaned and standardized text content in an array or string.

This library was originally developed with webpage spellchecking in mind, but can be used for any purpose you might have for it.

Installation

npm install extract-dom-content

API

extractDomContent(originalNode, [options]) ⇒ String | Array

Takes in a DOM element and returns all of its text content.

Param Type Default Description
originalNode Element DOM element to get the content from.
[options] Object {} An object of options to apply additionals filters and/or change the return type.
[options.returnAsArray] boolean false Whether the content should be returned as a linebreak-separated string or an array of strings.
[options.removeDuplicates] boolean false Whether duplicate strings should be removed or kept.

Browser & Virtual DOM support

This package supports nodes from:

  • regular browser DOMs (tested in Google Chrome) ✅
  • jsdom

If you have tried the package with a different virtual DOM package/library, please let us know how it went so we can add the information on this page.

Contributing

If you would like to add features, fix bugs or optimize this package, feel free to fork this repository and submit a pull request.

About

Get all of a DOM element's cleaned and standardized text content.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published