diff --git a/CHANGELOG.md b/CHANGELOG.md index e1404f1..0b04e31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +v0.22.0 + +- DX Improved. +- CheerioOptions and Fragment Mode support added. + +```ts +parse(data, config, options?: CheerioOptions, isDocument?: boolean) +``` + v0.21.0 - Dependencies updated. @@ -15,13 +24,7 @@ v0.19.0 ```ts { - fill: null; -} -{ - fill: false; -} -{ - fill: ''; + fill: null | false | ''; } ``` diff --git a/package.json b/package.json index f3ac120..ccd25d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muninn", - "version": "0.21.2", + "version": "0.22.0", "description": "It parses the html and collects the requested data as desired.", "main": "build/index.js", "scripts": { diff --git a/src/parser/parse.ts b/src/parser/parse.ts index df64c4f..39a1aa1 100644 --- a/src/parser/parse.ts +++ b/src/parser/parse.ts @@ -1,16 +1,32 @@ -import { load, CheerioAPI } from 'cheerio'; +import { load, CheerioAPI, CheerioOptions } from 'cheerio'; import { Config } from '../config/types'; import { getRawConfig } from './getRawConfig'; import getValue from './getValue'; +/** + * Create a JSON output using the provided schema and markup. + * + * Note that similar to web browser contexts, this operation may introduce + * ``, ``, and `` elements; set `isDocument` to `false` to + * switch to fragment mode and disable this. + * + * @param content - Markup to be loaded or a cheerio instance. + * @param config - Your parse config including your schema + * @param options - Cheerio options for the created instance. + * @param isDocument - Allows cheerio parser to be switched to fragment mode. + * @returns Your JSON output parsed according to your schema. + * @see {@link https://wopehq.gitbook.io/muninn} for additional usage information. + */ function parse( data: string | CheerioAPI, - config: Config + config: Config, + options?: CheerioOptions, + isDocument?: boolean ): Record { let $; if (typeof data === 'string') { - $ = load(data); + $ = load(data, options, isDocument); } else if (typeof data === 'function') { $ = data; }