0.0.5 • Published 4 years ago
@sansa-app/parser v0.0.5
parser
Common set of parsers for Sansa Chrome Extension and Backend
Installation
yarn add @sansa-app/parser
NPM Scripts
yarn build
- To build the packageyarn dev
- To run the package locally in developement mode. Required for testing the libraryyarn publish --access public
- To publish the library to npm Once we make the package private, we won't require the--access public
flag
Testing locally
To test the library locally, without publishing to npm, first setup the example directory as
cd example
yarn install
Once the dependencies are installed in the example directory, you can start the dev server in the root directory
yarn dev
and you can check whether the parser can parse a particular website using the example present in the example
directory
cd example
node index.js https://www.nytimes.com/2020/06/05/sports/the-athletic-layoffs.html
Creating new parser
To add a new parser, add the content
and url
in newsWebsites.ts
file. There are some helper functions present in utils
such as
getContentFromTextNodes
- merge all the content from the text nodes into a single string
Trouble Shooting
If there are some errors while building the package like Unexpected Token
, remove the node_modules
and install them again in the root directory
rm -rf node_module && yarn install