@flex-development/docmark-factory-space 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) 2024, 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,107 @@
1
+ # docmark-factory-space
2
+
3
+ [![npm](https://img.shields.io/npm/v/@flex-development/docmark-factory-space.svg)](https://npmjs.com/package/@flex-development/docmark-factory-space)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@flex-development/docmark-factory-space.svg)](https://www.npmcharts.com/compare/@flex-development/docmark-factory-space?interval=30)
5
+ [![install size](https://packagephobia.now.sh/badge?p=@flex-development/docmark-factory-space)](https://packagephobia.now.sh/result?p=@flex-development/docmark-factory-space)
6
+ [![minified bundle size](https://badgen.net/bundlephobia/min/@flex-development/docmark-factory-space?cache)](https://bundlephobia.com/package/@flex-development/docmark-factory-space)
7
+ [![tree shaking suppport](https://badgen.net/bundlephobia/tree-shaking/@flex-development/docmark-factory-space)](https://bundlephobia.com/package/@flex-development/docmark-factory-space)
8
+ [![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)
9
+ [![license](https://img.shields.io/github/license/flex-development/docmark-factory-space.svg)](LICENSE.md)
10
+ [![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript\&logoColor=ffffff)](https://typescriptlang.org)
11
+ [![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat\&logo=yarn\&logoColor=ffffff)](https://yarnpkg.com)
12
+
13
+ [docmark][] factory to parse [docdown space][ws].
14
+
15
+ ## Contents
16
+
17
+ - [What is this?](#what-is-this)
18
+ - [When should I use this?](#when-should-i-use-this)
19
+ - [Install](#install)
20
+ - [Use](#use)
21
+ - [API](#api)
22
+ - [Types](#types)
23
+ - [Contribute](#contribute)
24
+
25
+ ## What is this?
26
+
27
+ This package exposes states to parse spaces and/or tabs.
28
+
29
+ ## When should I use this?
30
+
31
+ This package may be useful when making your own docmark extensions.
32
+
33
+ ## Install
34
+
35
+ This package is [ESM only][esm].
36
+
37
+ In Node.js with [yarn][]:
38
+
39
+ ```sh
40
+ yarn add @flex-development/docmark-factory-space
41
+ ```
42
+
43
+ <blockquote>
44
+ <small>
45
+ See <a href='https://yarnpkg.com/protocol/git'>Git - Protocols | Yarn</a>
46
+ &nbsp;for details regarding installing from Git.
47
+ </small>
48
+ </blockquote>
49
+
50
+ In Deno with [`esm.sh`][esmsh]:
51
+
52
+ ```ts
53
+ import { factorySpace } from 'https://esm.sh/@flex-development/docmark-factory-space'
54
+ ```
55
+
56
+ In browsers with [`esm.sh`][esmsh]:
57
+
58
+ ```html
59
+ <script type="module">
60
+ import { factorySpace } from 'https://esm.sh/@flex-development/docmark-factory-space'
61
+ </script>
62
+ ```
63
+
64
+ ## Use
65
+
66
+ **TODO**: use
67
+
68
+ ## API
69
+
70
+ **TODO**: api
71
+
72
+ ## Types
73
+
74
+ This package is fully typed with [TypeScript][].
75
+ It exports no additional types.
76
+
77
+ ## Project
78
+
79
+ ### Version
80
+
81
+ docmark-factory-space adheres to [semver][].
82
+
83
+ ### Contribute
84
+
85
+ See [`CONTRIBUTING.md`](../../CONTRIBUTING.md).
86
+
87
+ This project has a [code of conduct](../../CODE_OF_CONDUCT.md).
88
+ By interacting with this repository, organization, or community you agree to abide by its terms.
89
+
90
+ ### Sponsor
91
+
92
+ Small primitives power larger systems.
93
+ Support long-term stability by sponsoring Flex Development.
94
+
95
+ [docmark]: ../../README.md
96
+
97
+ [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
98
+
99
+ [esmsh]: https://esm.sh
100
+
101
+ [semver]: https://semver.org
102
+
103
+ [typescript]: https://www.typescriptlang.org
104
+
105
+ [ws]: https://github.com/micromark/micromark/tree/main/packages/micromark-util-character#markdownlineendingorspacecode
106
+
107
+ [yarn]: https://yarnpkg.com
@@ -0,0 +1,30 @@
1
+ import type { Effects, State, TokenType } from '@flex-development/docmark-util-types';
2
+ import type * as micromark from 'micromark-util-types';
3
+
4
+ /**
5
+ * @file factorySpace
6
+ * @module docmark-factory-space/factory
7
+ */
8
+
9
+ /**
10
+ * Tokenize spaces and tabs.
11
+ *
12
+ * @see {@linkcode Effects}
13
+ * @see {@linkcode State}
14
+ * @see {@linkcode TokenType}
15
+ * @see {@linkcode micromark.Effects}
16
+ *
17
+ * @param {Effects | micromark.Effects} effects
18
+ * The context object used to transition the state machine
19
+ * @param {State} ok
20
+ * The successful tokenization state
21
+ * @param {TokenType | null | undefined} [type]
22
+ * The token type to capture whitespace as
23
+ * @param {number | null | undefined} [max]
24
+ * The maximum number of spaces/tabs to consume (exclusive)
25
+ * @return {State}
26
+ * The initial state
27
+ */
28
+ declare function factorySpace(effects: Effects | micromark.Effects, ok: State, type?: TokenType | null | undefined, max?: number | null | undefined): State;
29
+
30
+ export { factorySpace };
package/dist/index.mjs ADDED
@@ -0,0 +1,22 @@
1
+ import { whitespace } from '@flex-development/mark-util-character';
2
+
3
+ function factorySpace(effects, ok, type, max) {
4
+ const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
5
+ let size = 0;
6
+ return maybeWhitespace;
7
+ function maybeWhitespace(code) {
8
+ if (!whitespace(code))
9
+ return ok(code);
10
+ return type && effects.enter(type), insideWhitespace(code);
11
+ }
12
+ function insideWhitespace(code) {
13
+ if (whitespace(code) && size++ < limit) {
14
+ effects.consume(code);
15
+ return insideWhitespace;
16
+ }
17
+ type && effects.exit(type);
18
+ return ok(code);
19
+ }
20
+ }
21
+
22
+ export { factorySpace };
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@flex-development/docmark-factory-space",
3
+ "description": "docmark factory to parse docmark space",
4
+ "version": "1.0.0-alpha.1",
5
+ "keywords": [
6
+ "docmark",
7
+ "factory",
8
+ "space",
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-space",
13
+ "repository": {
14
+ "directory": "packages/docmark-factory-space",
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-space",
26
+ "diff-src-prefix": "docmark-factory-space",
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-space"
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-types": "1.0.0-alpha.1",
53
+ "@flex-development/mark-util-character": "1.1.0",
54
+ "micromark-util-types": "2.0.2"
55
+ },
56
+ "sideEffects": false,
57
+ "build": "524f7d653272a777cde27efaac4656fb90cd4855"
58
+ }