@flex-development/docmark-factory-identifier 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Flex Development, LLC All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its contributors
16
+ may be used to endorse or promote products derived from this software without
17
+ specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # docmark-factory-identifier
2
+
3
+ [![github release](https://img.shields.io/github/v/release/flex-development/docmark.svg?include_prereleases\&sort=date\&filter=docmark-factory-identifier%40*)](https://github.com/flex-development/docmark/releases/latest)
4
+ [![npm](https://img.shields.io/npm/v/@flex-development/docmark-factory-identifier.svg)](https://npmjs.com/package/@flex-development/docmark-factory-identifier)
5
+ [![npm downloads](https://img.shields.io/npm/dm/@flex-development/docmark-factory-identifier.svg)](https://www.npmcharts.com/compare/@flex-development/docmark-factory-identifier?interval=30)
6
+ [![minified bundle size](https://badgen.net/bundlephobia/min/@flex-development/docmark-factory-identifier?cache)](https://bundlephobia.com/package/@flex-development/docmark-factory-identifier)
7
+ [![install size](https://packagephobia.now.sh/badge?p=@flex-development/docmark-factory-identifier)](https://packagephobia.now.sh/result?p=@flex-development/docmark-factory-identifier)
8
+ [![tree shaking suppport](https://badgen.net/bundlephobia/tree-shaking/@flex-development/docmark-factory-identifier)](https://bundlephobia.com/package/@flex-development/docmark-factory-identifier)
9
+ [![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)
10
+ [![license](https://img.shields.io/github/license/flex-development/docmark)](LICENSE.md)
11
+
12
+ [docmark][] factory to parse identifiers.
13
+
14
+ ## Contents
15
+
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
+ - [Types](#types)
22
+ - [Contribute](#contribute)
23
+
24
+ ## What is this?
25
+
26
+ This package exposes states to parse identifiers.
27
+
28
+ ## When should I use this?
29
+
30
+ This package may be useful when making your own docmark extensions.
31
+
32
+ ## Install
33
+
34
+ This package is [ESM only][esm].
35
+
36
+ In Node.js with [yarn][]:
37
+
38
+ ```sh
39
+ yarn add @flex-development/docmark-factory-identifier
40
+ ```
41
+
42
+ <blockquote>
43
+ <small>
44
+ See <a href='https://yarnpkg.com/protocol/git'>Git - Protocols | Yarn</a>
45
+ &nbsp;for details regarding installing from Git.
46
+ </small>
47
+ </blockquote>
48
+
49
+ In Deno with [`esm.sh`][esmsh]:
50
+
51
+ ```ts
52
+ import { factoryIdentifier } from 'https://esm.sh/@flex-development/docmark-factory-identifier'
53
+ ```
54
+
55
+ In browsers with [`esm.sh`][esmsh]:
56
+
57
+ ```html
58
+ <script type="module">
59
+ import { factoryIdentifier } from 'https://esm.sh/@flex-development/docmark-factory-identifier'
60
+ </script>
61
+ ```
62
+
63
+ ## Use
64
+
65
+ **TODO**: use
66
+
67
+ ## API
68
+
69
+ **TODO**: api
70
+
71
+ ## Types
72
+
73
+ This package is fully typed with [TypeScript][].
74
+ It exports no additional types.
75
+
76
+ ## Project
77
+
78
+ ### Version
79
+
80
+ docmark-factory-identifier adheres to [semver][].
81
+
82
+ ### Contribute
83
+
84
+ See [`CONTRIBUTING.md`](../../CONTRIBUTING.md).
85
+
86
+ This project has a [code of conduct](../../CODE_OF_CONDUCT.md).
87
+ By interacting with this repository, organization, or community you agree to abide by its terms.
88
+
89
+ ### Sponsor
90
+
91
+ Small primitives power larger systems.
92
+ Support long-term stability by sponsoring Flex Development.
93
+
94
+ [docmark]: ../../README.md
95
+
96
+ [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
97
+
98
+ [esmsh]: https://esm.sh
99
+
100
+ [semver]: https://semver.org
101
+
102
+ [typescript]: https://www.typescriptlang.org
103
+
104
+ [yarn]: https://yarnpkg.com
@@ -0,0 +1,29 @@
1
+ import type { Effects, State, TokenType } from '@flex-development/docmark-util-types';
2
+
3
+ /**
4
+ * @file factoryIdentifier
5
+ * @module docmark-factory-identifier/factory
6
+ */
7
+
8
+ /**
9
+ * Tokenize an identifier.
10
+ *
11
+ * @see {@linkcode Effects}
12
+ * @see {@linkcode State}
13
+ * @see {@linkcode TokenType}
14
+ *
15
+ * @param {Effects} effects
16
+ * The context object used to transition the state machine
17
+ * @param {State} ok
18
+ * The successful tokenization state
19
+ * @param {State} nok
20
+ * The failed tokenization state
21
+ * @param {TokenType | null | undefined} [type]
22
+ * The token type to capture the identifier as.
23
+ * If omitted, defaults to {@linkcode tt.identifier}
24
+ * @return {State}
25
+ * The initial state
26
+ */
27
+ declare function factoryIdentifier(effects: Effects, ok: State, nok: State, type?: TokenType | null | undefined): State;
28
+
29
+ export { factoryIdentifier };
package/dist/index.mjs ADDED
@@ -0,0 +1,22 @@
1
+ import { tt } from '@flex-development/docmark-util-symbol';
2
+ import { idStart, idContinue } from '@flex-development/mark-util-character';
3
+
4
+ function factoryIdentifier(effects, ok, nok, type) {
5
+ type ??= tt.identifier;
6
+ return startIdentifier;
7
+ function startIdentifier(code) {
8
+ if (!idStart(code))
9
+ return nok(code);
10
+ effects.enter(type);
11
+ effects.consume(code);
12
+ return continueIdentifier;
13
+ }
14
+ function continueIdentifier(code) {
15
+ if (idContinue(code))
16
+ return effects.consume(code), continueIdentifier;
17
+ effects.exit(type);
18
+ return ok(code);
19
+ }
20
+ }
21
+
22
+ export { factoryIdentifier };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@flex-development/docmark-factory-identifier",
3
+ "description": "docmark factory to parse identifiers",
4
+ "version": "1.0.0-alpha.1",
5
+ "keywords": [
6
+ "docmark",
7
+ "factory",
8
+ "identifier",
9
+ "typescript"
10
+ ],
11
+ "license": "BSD-3-Clause",
12
+ "homepage": "https://github.com/flex-development/docmark-util-types/tree/main/packages/flex-development/docmark-factory-identifier",
13
+ "repository": {
14
+ "directory": "packages/docmark-factory-identifier",
15
+ "type": "git",
16
+ "url": "git+https://github.com/flex-development/docmark.git"
17
+ },
18
+ "bugs": "https://github.com/flex-development/docmark/issues",
19
+ "author": {
20
+ "name": "Lexus Drumgold",
21
+ "url": "https://github.com/unicornware"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "diff-dst-prefix": "docmark-factory-identifier",
26
+ "diff-src-prefix": "docmark-factory-identifier",
27
+ "directory": "./",
28
+ "executableFiles": [],
29
+ "node-options": null,
30
+ "pack-destination": ".",
31
+ "parseable": true,
32
+ "prefer-dedupe": true,
33
+ "provenance": true,
34
+ "tag-version-prefix": "docmark-factory-identifier@"
35
+ },
36
+ "type": "module",
37
+ "files": [
38
+ "LICENSE.md",
39
+ "README.md",
40
+ "dist"
41
+ ],
42
+ "exports": {
43
+ ".": {
44
+ "docmark": "./src/index.mts",
45
+ "default": "./dist/index.mjs"
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
49
+ "module": "./dist/index.mjs",
50
+ "types": "./dist/index.d.mts",
51
+ "dependencies": {
52
+ "@flex-development/docmark-util-symbol": "1.0.0-alpha.6",
53
+ "@flex-development/docmark-util-types": "1.0.0-alpha.9",
54
+ "@flex-development/mark-util-character": "1.1.0"
55
+ },
56
+ "sideEffects": false,
57
+ "build": "941f59f6a224a6bd607d55df60276b2283de1520"
58
+ }