parse-latin
Advanced tools
Comparing version 6.0.0 to 6.0.1
export class ParseLatin { | ||
/** | ||
* @param {string|null|undefined} [doc] | ||
* @param {VFile|null|undefined} [file] | ||
* Create a new parser. | ||
* | ||
* This additionally supports `retext`-like call: where an instance is | ||
* created for each file, and the file is given on construction. | ||
* | ||
* @param {string | null | undefined} [doc] | ||
* Value to parse. | ||
* @param {VFile | null | undefined} [file] | ||
* Corresponding file. | ||
*/ | ||
constructor(doc?: string | null | undefined, file?: VFile | null | undefined) | ||
/** @type {string|null} */ | ||
/** @type {string | null} */ | ||
doc: string | null | ||
@@ -16,38 +23,46 @@ /** @type {Array<(node: Root) => void>} */ | ||
/** | ||
* Easy access to the document parser. | ||
* This additionally supports `retext`-like call: where an instance is | ||
* created for each file, and the file is given on construction. | ||
* Turn natural language into a syntax tree. | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Root} | ||
* Tree. | ||
*/ | ||
parse(value?: string | undefined | null): Root | ||
parse(value?: string | null | undefined): Root | ||
/** | ||
* Parse as a root. | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Root} | ||
* Built tree. | ||
*/ | ||
tokenizeRoot(value?: string | undefined | null): Root | ||
tokenizeRoot(value?: string | null | undefined): Root | ||
/** | ||
* Parse as a paragraph. | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Paragraph} | ||
* Built tree. | ||
*/ | ||
tokenizeParagraph(value?: string | undefined | null): Paragraph | ||
tokenizeParagraph(value?: string | null | undefined): Paragraph | ||
/** | ||
* Parse as a sentence. | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Sentence} | ||
* Built tree. | ||
*/ | ||
tokenizeSentence(value?: string | undefined | null): Sentence | ||
tokenizeSentence(value?: string | null | undefined): Sentence | ||
/** | ||
* Transform a `value` into a list of `NLCSTNode`s. | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Array<SentenceContent>} | ||
* Built sentence content. | ||
*/ | ||
tokenize(value?: string | undefined | null): Array<SentenceContent> | ||
tokenize(value?: string | null | undefined): Array<SentenceContent> | ||
} | ||
@@ -54,0 +69,0 @@ export type VFile = import('vfile').VFile |
@@ -43,4 +43,11 @@ /** | ||
/** | ||
* @param {string|null|undefined} [doc] | ||
* @param {VFile|null|undefined} [file] | ||
* Create a new parser. | ||
* | ||
* This additionally supports `retext`-like call: where an instance is | ||
* created for each file, and the file is given on construction. | ||
* | ||
* @param {string | null | undefined} [doc] | ||
* Value to parse. | ||
* @param {VFile | null | undefined} [file] | ||
* Corresponding file. | ||
*/ | ||
@@ -50,3 +57,3 @@ constructor(doc, file) { | ||
/** @type {string|null} */ | ||
/** @type {string | null} */ | ||
this.doc = value ? String(value) : null | ||
@@ -63,8 +70,8 @@ | ||
/** | ||
* Easy access to the document parser. | ||
* This additionally supports `retext`-like call: where an instance is | ||
* created for each file, and the file is given on construction. | ||
* Turn natural language into a syntax tree. | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Root} | ||
* Tree. | ||
*/ | ||
@@ -78,4 +85,6 @@ parse(value) { | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Root} | ||
* Built tree. | ||
*/ | ||
@@ -101,4 +110,6 @@ tokenizeRoot(value) { | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Paragraph} | ||
* Built tree. | ||
*/ | ||
@@ -124,4 +135,6 @@ tokenizeParagraph(value) { | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Sentence} | ||
* Built tree. | ||
*/ | ||
@@ -144,4 +157,6 @@ tokenizeSentence(value) { | ||
* | ||
* @param {string|undefined|null} [value] | ||
* @param {string | null | undefined} [value] | ||
* Value to parse. | ||
* @returns {Array<SentenceContent>} | ||
* Built sentence content. | ||
*/ | ||
@@ -160,5 +175,5 @@ tokenize(value) { | ||
let start = {...currentPoint} | ||
/** @type {SentenceContent['type']|undefined} */ | ||
/** @type {SentenceContent['type'] | undefined} */ | ||
let previousType | ||
/** @type {string|undefined} */ | ||
/** @type {string | undefined} */ | ||
let previous | ||
@@ -217,6 +232,8 @@ | ||
/** | ||
* | ||
* @param {SentenceContent['type']} type | ||
* Node type to build. | ||
* @param {string} value | ||
* Value. | ||
* @returns {SentenceContent} | ||
* Node. | ||
*/ | ||
@@ -279,6 +296,11 @@ function createNode(type, value) { | ||
* @template {Parent} TheNode | ||
* Node type. | ||
* @param {TheNode} node | ||
* Node to split. | ||
* @param {RegExp} expression | ||
* Split on this regex. | ||
* @param {Content['type']} childType | ||
* Split this node type. | ||
* @returns {Array<TheNode>} | ||
* The given node, split into several nodes. | ||
*/ | ||
@@ -285,0 +307,0 @@ function splitNode(node, childType, expression) { |
@@ -12,3 +12,3 @@ /** | ||
/** | ||
* @type {import('unist-util-visit-children').Visitor<Paragraph|Root>} | ||
* @type {import('unist-util-visit-children').Visitor<Paragraph | Root>} | ||
*/ | ||
@@ -15,0 +15,0 @@ function (child, index, parent) { |
@@ -13,3 +13,3 @@ /** | ||
/** | ||
* @type {import('unist-util-visit-children').Visitor<Paragraph|Sentence|Root>} | ||
* @type {import('unist-util-visit-children').Visitor<Paragraph | Sentence | Root>} | ||
*/ | ||
@@ -20,2 +20,3 @@ function (child, index, node) { | ||
if ( | ||
child.position && | ||
index < 1 && | ||
@@ -31,2 +32,3 @@ /* c8 ignore next */ | ||
if ( | ||
child.position && | ||
index === siblings.length - 1 && | ||
@@ -33,0 +35,0 @@ (!node.position || !node.position.end) |
{ | ||
"name": "parse-latin", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "Latin-script (natural language) parser", | ||
@@ -56,3 +56,3 @@ "license": "MIT", | ||
"unist-util-remove-position": "^4.0.0", | ||
"xo": "^0.52.0" | ||
"xo": "^0.53.0" | ||
}, | ||
@@ -62,4 +62,4 @@ "scripts": { | ||
"fixture": "node script/generate-fixture.js", | ||
"generate": "node script/build-expressions.js", | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"generate": "node script/build-expressions.js", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
@@ -66,0 +66,0 @@ "test-api": "node --conditions development test/index.js", |
@@ -53,3 +53,3 @@ # parse-latin | ||
This package is [ESM only][esm]. | ||
In Node.js (version 14.14+, 16.0+), install with [npm][]: | ||
In Node.js (version 14.14+ and 16.0+), install with [npm][]: | ||
@@ -115,12 +115,11 @@ ```sh | ||
##### Parameters | ||
###### Parameters | ||
###### `value` | ||
* `value` (`string`, optional) | ||
— value to parse | ||
Value to parse (`string`). | ||
###### Returns | ||
##### Returns | ||
Tree ([`RootNode`][root]). | ||
[`RootNode`][root]. | ||
## Algorithm | ||
@@ -127,0 +126,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69659
1319
223