CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
1# micromark-util-classify-character2 3[![Build][build-badge]][build]4[![Coverage][coverage-badge]][coverage]5[![Downloads][downloads-badge]][downloads]6[![Size][bundle-size-badge]][bundle-size]7[![Sponsors][sponsors-badge]][opencollective]8[![Backers][backers-badge]][opencollective]9[![Chat][chat-badge]][chat]10 11[micromark][] utility to classify whether a character is whitespace or12punctuation.13 14## Contents15 16* [What is this?](#what-is-this)17* [When should I use this?](#when-should-i-use-this)18* [Install](#install)19* [Use](#use)20* [API](#api)21  * [`classifyCharacter(code)`](#classifycharactercode)22* [Types](#types)23* [Compatibility](#compatibility)24* [Security](#security)25* [Contribute](#contribute)26* [License](#license)27 28## What is this?29 30This package exposes an algorithm to classify characters into 3 categories.31 32## When should I use this?33 34This package might be useful when you are making your own micromark extensions.35 36## Install37 38This package is [ESM only][esm].39In Node.js (version 16+), install with [npm][]:40 41```sh42npm install micromark-util-classify-character43```44 45In Deno with [`esm.sh`][esmsh]:46 47```js48import {classifyCharacter} from 'https://esm.sh/micromark-util-classify-character@1'49```50 51In browsers with [`esm.sh`][esmsh]:52 53```html54<script type="module">55  import {classifyCharacter} from 'https://esm.sh/micromark-util-classify-character@1?bundle'56</script>57```58 59## Use60 61```js62/**63 * @this {TokenizeContext}64 *   Context.65 * @type {Tokenizer}66 */67function tokenizeAttention(effects, ok) {68  return start69 70  // …71 72  /** @type {State} */73  function sequence(code) {74    if (code === marker) {75      // …76    }77 78    const token = effects.exit('attentionSequence')79    const after = classifyCharacter(code)80    const open =81      !after || (after === constants.characterGroupPunctuation && before)82    const close =83      !before || (before === constants.characterGroupPunctuation && after)84    // …85  }86 87  // …88}89```90 91## API92 93This module exports the identifier94[`classifyCharacter`][api-classify-character].95There is no default export.96 97### `classifyCharacter(code)`98 99Classify whether a code represents whitespace, punctuation, or something100else.101 102Used for attention (emphasis, strong), whose sequences can open or close103based on the class of surrounding characters.104 105> 👉 **Note**: eof (`null`) is seen as whitespace.106 107###### Parameters108 109* `code` (`Code`)110  — code111 112###### Returns113 114Group (`constants.characterGroupWhitespace`,115`constants.characterGroupPunctuation`, or `undefined`).116 117## Types118 119This package is fully typed with [TypeScript][].120It exports no additional types.121 122## Compatibility123 124Projects maintained by the unified collective are compatible with maintained125versions of Node.js.126 127When we cut a new major release, we drop support for unmaintained versions of128Node.129This means we try to keep the current release line,130`micromark-util-classify-character@2`, compatible with Node.js 16.131This package works with `micromark@3`.132 133## Security134 135This package is safe.136See [`security.md`][securitymd] in [`micromark/.github`][health] for how to137submit a security report.138 139## Contribute140 141See [`contributing.md`][contributing] in [`micromark/.github`][health] for ways142to get started.143See [`support.md`][support] for ways to get help.144 145This project has a [code of conduct][coc].146By interacting with this repository, organisation, or community you agree to147abide by its terms.148 149## License150 151[MIT][license] © [Titus Wormer][author]152 153<!-- Definitions -->154 155[build-badge]: https://github.com/micromark/micromark/workflows/main/badge.svg156 157[build]: https://github.com/micromark/micromark/actions158 159[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark.svg160 161[coverage]: https://codecov.io/github/micromark/micromark162 163[downloads-badge]: https://img.shields.io/npm/dm/micromark-util-classify-character.svg164 165[downloads]: https://www.npmjs.com/package/micromark-util-classify-character166 167[bundle-size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-util-classify-character168 169[bundle-size]: https://bundlejs.com/?q=micromark-util-classify-character170 171[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg172 173[backers-badge]: https://opencollective.com/unified/backers/badge.svg174 175[opencollective]: https://opencollective.com/unified176 177[npm]: https://docs.npmjs.com/cli/install178 179[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c180 181[esmsh]: https://esm.sh182 183[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg184 185[chat]: https://github.com/micromark/micromark/discussions186 187[license]: https://github.com/micromark/micromark/blob/main/license188 189[author]: https://wooorm.com190 191[health]: https://github.com/micromark/.github192 193[securitymd]: https://github.com/micromark/.github/blob/main/security.md194 195[contributing]: https://github.com/micromark/.github/blob/main/contributing.md196 197[support]: https://github.com/micromark/.github/blob/main/support.md198 199[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md200 201[typescript]: https://www.typescriptlang.org202 203[micromark]: https://github.com/micromark/micromark204 205[api-classify-character]: #classifycharactercode206