spelledright

1.0.0 • Public • Published

Coverage Status Bitdeli Badge

spelledright

This project is a js library used to facilitate spell checks on XML, HTML pages in English. It wraps around cfinke/Typo.js. You can directly take the spelledright.js file and add it to your project.

The Mechanism

The way it works is by:

    1. Parsing all children under a specified XML Node.
    1. Gathering all elements innertext
    1. Going throws the gat hered innertext and (logically) breaking it up into words
    1. Performing a spelling check on each word according to the desired options config

Example Usage

// 1) Load a page using a UI test driver ex.
// selenium-webdriver (https://www.npmjs.com/package/selenium-webdriver)
let driver = new webdriver.Builder().forBrowser('firefox').build();
driver.get(URL).then(() => {
  // 2) Get the target node to perform checks on the target children
  return driver.executeScript(`
    return document.getElementsByTagName('body')[0];
  `);
}).then(node => {
  // 3) Return the inner HTML (Library initialization as string node is supported)
  return node.getInnerHtml();
}).then(inner => {
  // 4) Use the library with your asserts, or logs
  let spelledright = new SpelledRight(inner, {
    ignoreCase: false,
    ignoreComments: true,
    whitelist: [/^[A-Z]+$/ /* All caps letters */]
  });
  console.log('Misspellings are: ' +
    JSON.stringify(spelledright.getMisspellings()));
  return driver.quit();
})

Note See the spec files for concrete examples.

Additional Usage

To run this project locally, or contribute:

    1. npm install Make sure everything is installed.
  • 2)grunt babel Convert es6 files to the js counterparts.
    1. npm run-script unittest && npm run-script perftest Make sure tests are working.
    1. grunt watch Anytime before developing. Note: The project is linted extend from google.
    1. Develop!
    1. Don't forget to add tests and test it out! Let's aim to keep coverage >= 93% Performance benchmarks should be roughly:
    • DETAILED_PAGE_BENCHMARK: 1040.511ms
    • SIMPLE_PAGE_BENCHMARK: 752.908ms
    1. npm build To ensure everything is in working order.
    1. Now we're talking, make a PR upstream.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0

Package Sidebar

Install

npm i spelledright

Weekly Downloads

0

Version

1.0.0

License

ISC

Last publish

Collaborators

  • tmillner