CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
1# micromark-util-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 handle [character codes][code].12 13## Contents14 15* [What is this?](#what-is-this)16* [When should I use this?](#when-should-i-use-this)17* [Install](#install)18* [Use](#use)19* [API](#api)20  * [`asciiAlpha(code)`](#asciialphacode)21  * [`asciiAlphanumeric(code)`](#asciialphanumericcode)22  * [`asciiAtext(code)`](#asciiatextcode)23  * [`asciiControl(code)`](#asciicontrolcode)24  * [`asciiDigit(code)`](#asciidigitcode)25  * [`asciiHexDigit(code)`](#asciihexdigitcode)26  * [`asciiPunctuation(code)`](#asciipunctuationcode)27  * [`markdownLineEnding(code)`](#markdownlineendingcode)28  * [`markdownLineEndingOrSpace(code)`](#markdownlineendingorspacecode)29  * [`markdownSpace(code)`](#markdownspacecode)30  * [`unicodePunctuation(code)`](#unicodepunctuationcode)31  * [`unicodeWhitespace(code)`](#unicodewhitespacecode)32* [Types](#types)33* [Compatibility](#compatibility)34* [Security](#security)35* [Contribute](#contribute)36* [License](#license)37 38## What is this?39 40This package exposes algorithms to check whether characters match groups.41 42## When should I use this?43 44This package might be useful when you are making your own micromark extensions.45 46## Install47 48This package is [ESM only][esm].49In Node.js (version 16+), install with [npm][]:50 51```sh52npm install micromark-util-character53```54 55In Deno with [`esm.sh`][esmsh]:56 57```js58import * as character from 'https://esm.sh/micromark-util-character@1'59```60 61In browsers with [`esm.sh`][esmsh]:62 63```html64<script type="module">65  import * as character from 'https://esm.sh/micromark-util-character@1?bundle'66</script>67```68 69## Use70 71```js72import {asciiAlpha} from 'micromark-util-character'73 74console.log(asciiAlpha(64)) // false75console.log(asciiAlpha(65)) // true76```77 78## API79 80This module exports the identifiers81[`asciiAlpha`][api-ascii-alpha],82[`asciiAlphanumeric`][api-ascii-alphanumeric],83[`asciiAtext`][api-ascii-atext],84[`asciiControl`][api-ascii-control],85[`asciiDigit`][api-ascii-digit],86[`asciiHexDigit`][api-ascii-hex-digit],87[`asciiPunctuation`][api-ascii-punctuation],88[`markdownLineEnding`][api-markdown-line-ending],89[`markdownLineEndingOrSpace`][api-markdown-line-ending-or-space],90[`markdownSpace`][api-markdown-space],91[`unicodePunctuation`][api-unicode-punctuation],92[`unicodeWhitespace`][api-unicode-whitespace].93There is no default export.94 95### `asciiAlpha(code)`96 97Check whether the [character code][code] represents an ASCII alpha (`a` through98`z`, case insensitive).99 100An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha.101 102An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`)103to U+005A (`Z`).104 105An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`)106to U+007A (`z`).107 108###### Parameters109 110* `code` (`Code`)111  — code112 113###### Returns114 115Whether it matches (`boolean`).116 117### `asciiAlphanumeric(code)`118 119Check whether the [character code][code] represents an ASCII alphanumeric (`a`120through `z`, case insensitive, or `0` through `9`).121 122An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha123(see `asciiAlpha`).124 125###### Parameters126 127* `code` (`Code`)128  — code129 130###### Returns131 132Whether it matches (`boolean`).133 134### `asciiAtext(code)`135 136Check whether the [character code][code] represents an ASCII atext.137 138atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in139the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`),140U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F141SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E142CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE143(`{`) to U+007E TILDE (`~`) (**\[RFC5322]**).144 145See **\[RFC5322]**:\146[Internet Message Format](https://tools.ietf.org/html/rfc5322).\147P. Resnick.\148IETF.149 150###### Parameters151 152* `code` (`Code`)153  — code154 155###### Returns156 157Whether it matches (`boolean`).158 159### `asciiControl(code)`160 161Check whether a [character code][code] is an ASCII control character.162 163An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)164to U+001F (US), or U+007F (DEL).165 166###### Parameters167 168* `code` (`Code`)169  — code170 171###### Returns172 173Whether it matches (`boolean`).174 175### `asciiDigit(code)`176 177Check whether the [character code][code] represents an ASCII digit (`0` through178`9`).179 180An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to181U+0039 (`9`).182 183###### Parameters184 185* `code` (`Code`)186  — code187 188###### Returns189 190Whether it matches (`boolean`).191 192### `asciiHexDigit(code)`193 194Check whether the [character code][code] represents an ASCII hex digit (`a`195through `f`, case insensitive, or `0` through `9`).196 197An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex198digit, or an ASCII lower hex digit.199 200An **ASCII upper hex digit** is a character in the inclusive range U+0041201(`A`) to U+0046 (`F`).202 203An **ASCII lower hex digit** is a character in the inclusive range U+0061204(`a`) to U+0066 (`f`).205 206###### Parameters207 208* `code` (`Code`)209  — code210 211###### Returns212 213Whether it matches (`boolean`).214 215### `asciiPunctuation(code)`216 217Check whether the [character code][code] represents ASCII punctuation.218 219An **ASCII punctuation** is a character in the inclusive ranges U+0021220EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT221SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT222(`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`).223 224###### Parameters225 226* `code` (`Code`)227  — code228 229###### Returns230 231Whether it matches (`boolean`).232 233### `markdownLineEnding(code)`234 235Check whether a [character code][code] is a markdown line ending.236 237A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN238LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).239 240In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE241RETURN (CR) are replaced by these virtual characters depending on whether242they occurred together.243 244###### Parameters245 246* `code` (`Code`)247  — code248 249###### Returns250 251Whether it matches (`boolean`).252 253### `markdownLineEndingOrSpace(code)`254 255Check whether a [character code][code] is a markdown line ending (see256`markdownLineEnding`) or markdown space (see `markdownSpace`).257 258###### Parameters259 260* `code` (`Code`)261  — code262 263###### Returns264 265Whether it matches (`boolean`).266 267### `markdownSpace(code)`268 269Check whether a [character code][code] is a markdown space.270 271A **markdown space** is the concrete character U+0020 SPACE (SP) and the272virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).273 274In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is275replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL276SPACE (VS) characters, depending on the column at which the tab occurred.277 278###### Parameters279 280* `code` (`Code`)281  — code282 283###### Returns284 285Whether it matches (`boolean`).286 287### `unicodePunctuation(code)`288 289Check whether the [character code][code] represents Unicode punctuation.290 291A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation,292Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`293(Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`294(Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII295punctuation (see `asciiPunctuation`) (**\[UNICODE]**).296 297See **\[UNICODE]**:\298[The Unicode Standard](https://www.unicode.org/versions/).\299Unicode Consortium.300 301###### Parameters302 303* `code` (`Code`)304  — code305 306###### Returns307 308Whether it matches (`boolean`).309 310### `unicodeWhitespace(code)`311 312Check whether the [character code][code] represents Unicode whitespace.313 314Note that this does handle micromark specific markdown whitespace characters.315See `markdownLineEndingOrSpace` to check that.316 317A **Unicode whitespace** is a character in the Unicode `Zs` (Separator,318Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF),319U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**).320 321See **\[UNICODE]**:\322[The Unicode Standard](https://www.unicode.org/versions/).\323Unicode Consortium.324 325###### Parameters326 327* `code` (`Code`)328  — code329 330###### Returns331 332Whether it matches (`boolean`).333 334## Types335 336This package is fully typed with [TypeScript][].337It exports no additional types.338 339## Compatibility340 341Projects maintained by the unified collective are compatible with maintained342versions of Node.js.343 344When we cut a new major release, we drop support for unmaintained versions of345Node.346This means we try to keep the current release line,347`micromark-util-character@2`, compatible with Node.js 16.348This package works with `micromark@3`.349 350## Security351 352This package is safe.353See [`security.md`][securitymd] in [`micromark/.github`][health] for how to354submit a security report.355 356## Contribute357 358See [`contributing.md`][contributing] in [`micromark/.github`][health] for ways359to get started.360See [`support.md`][support] for ways to get help.361 362This project has a [code of conduct][coc].363By interacting with this repository, organisation, or community you agree to364abide by its terms.365 366## License367 368[MIT][license] © [Titus Wormer][author]369 370<!-- Definitions -->371 372[build-badge]: https://github.com/micromark/micromark/workflows/main/badge.svg373 374[build]: https://github.com/micromark/micromark/actions375 376[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark.svg377 378[coverage]: https://codecov.io/github/micromark/micromark379 380[downloads-badge]: https://img.shields.io/npm/dm/micromark-util-character.svg381 382[downloads]: https://www.npmjs.com/package/micromark-util-character383 384[bundle-size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-util-character385 386[bundle-size]: https://bundlejs.com/?q=micromark-util-character387 388[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg389 390[backers-badge]: https://opencollective.com/unified/backers/badge.svg391 392[opencollective]: https://opencollective.com/unified393 394[npm]: https://docs.npmjs.com/cli/install395 396[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c397 398[esmsh]: https://esm.sh399 400[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg401 402[chat]: https://github.com/micromark/micromark/discussions403 404[license]: https://github.com/micromark/micromark/blob/main/license405 406[author]: https://wooorm.com407 408[health]: https://github.com/micromark/.github409 410[securitymd]: https://github.com/micromark/.github/blob/main/security.md411 412[contributing]: https://github.com/micromark/.github/blob/main/contributing.md413 414[support]: https://github.com/micromark/.github/blob/main/support.md415 416[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md417 418[typescript]: https://www.typescriptlang.org419 420[micromark]: https://github.com/micromark/micromark421 422[code]: https://github.com/micromark/micromark#preprocess423 424[api-ascii-alpha]: #asciialphacode425 426[api-ascii-alphanumeric]: #asciialphanumericcode427 428[api-ascii-atext]: #asciiatextcode429 430[api-ascii-control]: #asciicontrolcode431 432[api-ascii-digit]: #asciidigitcode433 434[api-ascii-hex-digit]: #asciihexdigitcode435 436[api-ascii-punctuation]: #asciipunctuationcode437 438[api-markdown-line-ending]: #markdownlineendingcode439 440[api-markdown-line-ending-or-space]: #markdownlineendingorspacecode441 442[api-markdown-space]: #markdownspacecode443 444[api-unicode-punctuation]: #unicodepunctuationcode445 446[api-unicode-whitespace]: #unicodewhitespacecode447