-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦 feat(retext-german): add new package for parsing German natural lan…
…guage 🔧 chore(retext-german): add .npmrc and tsconfig.json for package configuration 📝 docs(retext-german): add readme.md for package documentation 🎉 init(retext-german): create index.js and lib/index.js for initial package setup 🔧 chore(retext-german): add package.json for package metadata and dependencies
- Loading branch information
Showing
6 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore-scripts=true | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Note: types exposed from `index.d.ts`. | ||
export {default} from './lib/index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @typedef {import('nlcst').Root} Root | ||
*/ | ||
|
||
import {ParseGerman} from 'parse-german' | ||
Check failure on line 5 in packages/retext-german/lib/index.js GitHub Actions / lts/gallium
|
||
|
||
/** | ||
* Add support for parsing German natural language. | ||
* | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
export default function retextGerman() { | ||
// @ts-expect-error -- TS in JSDoc doesn’t understand `this`. | ||
// eslint-disable-next-line unicorn/no-this-assignment | ||
const self = /** @type {import('unified').Processor<Root>} */ (this) | ||
|
||
self.parser = parser | ||
|
||
/** @type {import('unified').Parser<Root>} */ | ||
function parser(value) { | ||
const parser = new ParseGerman() | ||
add(parser.tokenizeParagraphPlugins, self.data('nlcstParagraphExtensions')) | ||
add(parser.tokenizeRootPlugins, self.data('nlcstRootExtensions')) | ||
add(parser.tokenizeSentencePlugins, self.data('nlcstSentenceExtensions')) | ||
return parser.parse(value) | ||
} | ||
} | ||
|
||
/** | ||
* @template T | ||
* @param {Array<T>} list | ||
* @param {Array<T> | undefined} values | ||
*/ | ||
function add(list, values) { | ||
if (values) list.unshift(...values) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"name": "retext-german", | ||
"version": "5.0.0", | ||
"description": "retext plugin to parse German prose", | ||
"license": "MIT", | ||
"keywords": [ | ||
"concrete", | ||
"cst", | ||
"german", | ||
"language", | ||
"natural", | ||
"parse", | ||
"plugin", | ||
"process", | ||
"retext", | ||
"retext-plugin", | ||
"syntax", | ||
"tree", | ||
"unified" | ||
], | ||
"homepage": "https://github.com/retextjs/retext", | ||
"repository": "https://github.com/retextjs/retext/tree/main/packages/retext-german", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/unified" | ||
}, | ||
"bugs": "https://github.com/retextjs/retext/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"files": [ | ||
"lib/", | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"@types/nlcst": "^2.0.0", | ||
"parse-german": "^0.0.1", | ||
"unified": "^11.0.0" | ||
}, | ||
"scripts": {}, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"ignoreCatch": true, | ||
"strict": true | ||
}, | ||
"xo": { | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
], | ||
"rules": { | ||
"@typescript-eslint/ban-types": "off", | ||
"@typescript-eslint/consistent-type-definitions": "off" | ||
} | ||
} | ||
], | ||
"prettier": true | ||
} | ||
} |
Oops, something went wrong.