@effected/markdown 0.4.2 → 0.5.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/Frontmatter.js +5 -5
- package/FrontmatterResolver.js +4 -4
- package/Markdown.js +5 -5
- package/MarkdownFormat.js +1 -1
- package/Mdast.js +1 -1
- package/internal/inlineParser.js +33 -32
- package/internal/references.js +7 -5
- package/package.json +5 -5
package/Frontmatter.js
CHANGED
|
@@ -14,7 +14,7 @@ import { Effect, Schema } from "effect";
|
|
|
14
14
|
*
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
var FrontmatterFormatMismatchError = class extends Schema.
|
|
17
|
+
var FrontmatterFormatMismatchError = class extends Schema.TaggedError()("FrontmatterFormatMismatchError", {
|
|
18
18
|
/** The format the codec decodes. */
|
|
19
19
|
expected: FrontmatterFormat,
|
|
20
20
|
/** The format the capture node actually carries. */
|
|
@@ -36,7 +36,7 @@ var FrontmatterFormatMismatchError = class extends Schema.TaggedErrorClass()("Fr
|
|
|
36
36
|
*
|
|
37
37
|
* @public
|
|
38
38
|
*/
|
|
39
|
-
var FrontmatterDecodeError = class extends Schema.
|
|
39
|
+
var FrontmatterDecodeError = class extends Schema.TaggedError()("FrontmatterDecodeError", {
|
|
40
40
|
/** The format that failed to parse. */
|
|
41
41
|
format: FrontmatterFormat,
|
|
42
42
|
/** The underlying format-package failure, preserved structurally. */
|
|
@@ -58,7 +58,7 @@ var FrontmatterDecodeError = class extends Schema.TaggedErrorClass()("Frontmatte
|
|
|
58
58
|
*
|
|
59
59
|
* @public
|
|
60
60
|
*/
|
|
61
|
-
var FrontmatterEncodeError = class extends Schema.
|
|
61
|
+
var FrontmatterEncodeError = class extends Schema.TaggedError()("FrontmatterEncodeError", {
|
|
62
62
|
/** The format that failed to serialize. */
|
|
63
63
|
format: FrontmatterFormat,
|
|
64
64
|
/** The underlying format-package failure, preserved structurally. */
|
|
@@ -101,7 +101,7 @@ const FrontmatterMissingReason = Schema.Literals(["absent", "captureDisabled"]);
|
|
|
101
101
|
*
|
|
102
102
|
* @public
|
|
103
103
|
*/
|
|
104
|
-
var FrontmatterMissingError = class extends Schema.
|
|
104
|
+
var FrontmatterMissingError = class extends Schema.TaggedError()("FrontmatterMissingError", {
|
|
105
105
|
/** Why there is no capture: no block at all, or capture left off. */
|
|
106
106
|
reason: FrontmatterMissingReason }) {
|
|
107
107
|
get message() {
|
|
@@ -121,7 +121,7 @@ reason: FrontmatterMissingReason }) {
|
|
|
121
121
|
*
|
|
122
122
|
* @public
|
|
123
123
|
*/
|
|
124
|
-
var FrontmatterValidationError = class extends Schema.
|
|
124
|
+
var FrontmatterValidationError = class extends Schema.TaggedError()("FrontmatterValidationError", {
|
|
125
125
|
/** The structured schema issue. Never a string. */
|
|
126
126
|
issue: Schema.Defect() }) {
|
|
127
127
|
get message() {
|
package/FrontmatterResolver.js
CHANGED
|
@@ -81,7 +81,7 @@ const SchemaDeclaration = Schema.Union([
|
|
|
81
81
|
*
|
|
82
82
|
* @public
|
|
83
83
|
*/
|
|
84
|
-
var SchemaDeclarationInvalidError = class extends Schema.
|
|
84
|
+
var SchemaDeclarationInvalidError = class extends Schema.TaggedError()("SchemaDeclarationInvalidError", {
|
|
85
85
|
/** Why the value failed to classify. */
|
|
86
86
|
reason: Schema.String,
|
|
87
87
|
/** The offending value, preserved structurally. */
|
|
@@ -98,7 +98,7 @@ var SchemaDeclarationInvalidError = class extends Schema.TaggedErrorClass()("Sch
|
|
|
98
98
|
*
|
|
99
99
|
* @public
|
|
100
100
|
*/
|
|
101
|
-
var SchemaDeclarationMissingError = class extends Schema.
|
|
101
|
+
var SchemaDeclarationMissingError = class extends Schema.TaggedError()("SchemaDeclarationMissingError", {}) {
|
|
102
102
|
get message() {
|
|
103
103
|
return "the frontmatter data carries no $schema declaration";
|
|
104
104
|
}
|
|
@@ -110,7 +110,7 @@ var SchemaDeclarationMissingError = class extends Schema.TaggedErrorClass()("Sch
|
|
|
110
110
|
*
|
|
111
111
|
* @public
|
|
112
112
|
*/
|
|
113
|
-
var SchemaNameUnknownError = class extends Schema.
|
|
113
|
+
var SchemaNameUnknownError = class extends Schema.TaggedError()("SchemaNameUnknownError", {
|
|
114
114
|
/** The declaration that failed to resolve, when one exists. */
|
|
115
115
|
declaration: Schema.optionalKey(SchemaDeclaration) }) {
|
|
116
116
|
get message() {
|
|
@@ -126,7 +126,7 @@ declaration: Schema.optionalKey(SchemaDeclaration) }) {
|
|
|
126
126
|
*
|
|
127
127
|
* @public
|
|
128
128
|
*/
|
|
129
|
-
var SchemaVersionUnresolvableError = class extends Schema.
|
|
129
|
+
var SchemaVersionUnresolvableError = class extends Schema.TaggedError()("SchemaVersionUnresolvableError", {
|
|
130
130
|
/** The registered name whose version could not be satisfied. */
|
|
131
131
|
name: Schema.String,
|
|
132
132
|
/** The requested version, when the declaration carried one. */
|
package/Markdown.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isGuardExceeded, isRawMarkdownError } from "./internal/carriers.js";
|
|
|
3
3
|
import { parseBlocks } from "./internal/blockParser.js";
|
|
4
4
|
import { stringifyTree } from "./internal/stringify.js";
|
|
5
5
|
import { MarkdownDiagnostic } from "./MarkdownDiagnostic.js";
|
|
6
|
-
import { Effect,
|
|
6
|
+
import { Effect, Result, Schema, SchemaIssue, SchemaTransformation } from "effect";
|
|
7
7
|
|
|
8
8
|
//#region src/Markdown.ts
|
|
9
9
|
/**
|
|
@@ -51,7 +51,7 @@ var MarkdownParseOptions = class extends Schema.Class("MarkdownParseOptions")({
|
|
|
51
51
|
*
|
|
52
52
|
* @public
|
|
53
53
|
*/
|
|
54
|
-
var MarkdownParseError = class extends Schema.
|
|
54
|
+
var MarkdownParseError = class extends Schema.TaggedError()("MarkdownParseError", { diagnostic: MarkdownDiagnostic }) {
|
|
55
55
|
get message() {
|
|
56
56
|
const { code, line, character, message } = this.diagnostic;
|
|
57
57
|
return `Markdown parse failed: ${code} at ${line}:${character} ${message}`;
|
|
@@ -72,7 +72,7 @@ var MarkdownParseError = class extends Schema.TaggedErrorClass()("MarkdownParseE
|
|
|
72
72
|
*
|
|
73
73
|
* @public
|
|
74
74
|
*/
|
|
75
|
-
var MarkdownStringifyError = class extends Schema.
|
|
75
|
+
var MarkdownStringifyError = class extends Schema.TaggedError()("MarkdownStringifyError", { diagnostic: MarkdownDiagnostic }) {
|
|
76
76
|
get message() {
|
|
77
77
|
const { code, message } = this.diagnostic;
|
|
78
78
|
return `Markdown stringify failed: ${code} ${message}`;
|
|
@@ -242,8 +242,8 @@ var Markdown = class Markdown {
|
|
|
242
242
|
*/
|
|
243
243
|
static fromString(options) {
|
|
244
244
|
return Schema.String.pipe(Schema.decodeTo(Root, SchemaTransformation.transformOrFail({
|
|
245
|
-
decode: (input) => Effect.mapError(Markdown.parse(input, options), (error) => new SchemaIssue.InvalidValue(
|
|
246
|
-
encode: (value) => Effect.mapError(Markdown.stringify(value), (error) => new SchemaIssue.InvalidValue(
|
|
245
|
+
decode: (input) => Effect.mapError(Markdown.parse(input, options), (error) => new SchemaIssue.InvalidValue({ message: error.message }, input)),
|
|
246
|
+
encode: (value) => Effect.mapError(Markdown.stringify(value), (error) => new SchemaIssue.InvalidValue({ message: error.message }, value))
|
|
247
247
|
})));
|
|
248
248
|
}
|
|
249
249
|
/**
|
package/MarkdownFormat.js
CHANGED
|
@@ -80,7 +80,7 @@ const MarkdownModificationErrorCode = Schema.Literals([
|
|
|
80
80
|
*
|
|
81
81
|
* @public
|
|
82
82
|
*/
|
|
83
|
-
var MarkdownModificationError = class extends Schema.
|
|
83
|
+
var MarkdownModificationError = class extends Schema.TaggedError()("MarkdownModificationError", {
|
|
84
84
|
code: MarkdownModificationErrorCode,
|
|
85
85
|
detail: Schema.String,
|
|
86
86
|
offset: Schema.Number,
|
package/Mdast.js
CHANGED
|
@@ -42,7 +42,7 @@ import { Effect, Result, Schema } from "effect";
|
|
|
42
42
|
*
|
|
43
43
|
* @public
|
|
44
44
|
*/
|
|
45
|
-
var MdastDecodeError = class extends Schema.
|
|
45
|
+
var MdastDecodeError = class extends Schema.TaggedError()("MdastDecodeError", {
|
|
46
46
|
/** The structured schema issue. Never a string. */
|
|
47
47
|
issue: Schema.Defect() }) {
|
|
48
48
|
get message() {
|
package/internal/inlineParser.js
CHANGED
|
@@ -219,39 +219,40 @@ var InlineParser = class {
|
|
|
219
219
|
opener = opener.previous;
|
|
220
220
|
}
|
|
221
221
|
const oldCloser = closer;
|
|
222
|
-
if (closercc === C_ASTERISK || closercc === C_UNDERSCORE)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
222
|
+
if (closercc === C_ASTERISK || closercc === C_UNDERSCORE) {
|
|
223
|
+
if (!openerFound || opener === void 0) closer = closer.next;
|
|
224
|
+
else {
|
|
225
|
+
const useDelims = closer.numdelims >= 2 && opener.numdelims >= 2 ? 2 : 1;
|
|
226
|
+
const openerNode = opener.node;
|
|
227
|
+
const closerNode = closer.node;
|
|
228
|
+
opener.numdelims -= useDelims;
|
|
229
|
+
closer.numdelims -= useDelims;
|
|
230
|
+
openerNode.value = openerNode.value.slice(0, openerNode.value.length - useDelims);
|
|
231
|
+
openerNode.end -= useDelims;
|
|
232
|
+
closerNode.value = closerNode.value.slice(0, closerNode.value.length - useDelims);
|
|
233
|
+
closerNode.start += useDelims;
|
|
234
|
+
const emphasis = makeInlineNode(useDelims === 1 ? "emphasis" : "strong", openerNode.end, closerNode.start);
|
|
235
|
+
emphasis.data.markerChar = closercc === C_UNDERSCORE ? "_" : "*";
|
|
236
|
+
let between = openerNode.next;
|
|
237
|
+
while (between !== void 0 && between !== closerNode) {
|
|
238
|
+
const following = between.next;
|
|
239
|
+
appendChild(emphasis, between);
|
|
240
|
+
between = following;
|
|
241
|
+
}
|
|
242
|
+
insertAfter(openerNode, emphasis);
|
|
243
|
+
this.removeDelimitersBetween(opener, closer);
|
|
244
|
+
if (opener.numdelims === 0) {
|
|
245
|
+
unlink(openerNode);
|
|
246
|
+
this.removeDelimiter(opener);
|
|
247
|
+
}
|
|
248
|
+
if (closer.numdelims === 0) {
|
|
249
|
+
unlink(closerNode);
|
|
250
|
+
const next = closer.next;
|
|
251
|
+
this.removeDelimiter(closer);
|
|
252
|
+
closer = next;
|
|
253
|
+
}
|
|
252
254
|
}
|
|
253
|
-
}
|
|
254
|
-
else if (closercc === 126) closer = !openerFound || opener === void 0 ? closer.next : insertStrikethrough(this, opener, closer);
|
|
255
|
+
} else if (closercc === 126) closer = !openerFound || opener === void 0 ? closer.next : insertStrikethrough(this, opener, closer);
|
|
255
256
|
else closer = closer.next;
|
|
256
257
|
if (!openerFound) {
|
|
257
258
|
openersBottom[openersBottomIndex] = oldCloser.previous;
|
package/internal/references.js
CHANGED
|
@@ -154,11 +154,13 @@ const parseReference = (text) => {
|
|
|
154
154
|
let title = scanner.pos === beforeTitle ? void 0 : scanner.parseLinkTitle();
|
|
155
155
|
if (title === void 0) scanner.pos = beforeTitle;
|
|
156
156
|
let atLineEnd = true;
|
|
157
|
-
if (scanner.match(reSpaceAtEndOfLine) === void 0)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
if (scanner.match(reSpaceAtEndOfLine) === void 0) {
|
|
158
|
+
if (title === void 0) atLineEnd = false;
|
|
159
|
+
else {
|
|
160
|
+
title = void 0;
|
|
161
|
+
scanner.pos = beforeTitle;
|
|
162
|
+
atLineEnd = scanner.match(reSpaceAtEndOfLine) !== void 0;
|
|
163
|
+
}
|
|
162
164
|
}
|
|
163
165
|
if (!atLineEnd) return;
|
|
164
166
|
const key = normalizeReference(rawLabel);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "CommonMark and GFM markdown parse, edit and transform schemas for Effect",
|
|
6
6
|
"keywords": [
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"./package.json": "./package.json"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@effected/jsonc": "^0.
|
|
43
|
-
"@effected/toml": "^0.
|
|
44
|
-
"@effected/yaml": "^0.
|
|
45
|
-
"effect": "4.0.0-beta.
|
|
42
|
+
"@effected/jsonc": "^0.6.0",
|
|
43
|
+
"@effected/toml": "^0.4.0",
|
|
44
|
+
"@effected/yaml": "^0.8.0",
|
|
45
|
+
"effect": "4.0.0-beta.107"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"@effected/jsonc": {
|