@markdoc/markdoc 0.1.10 → 0.1.12
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/dist/index.js +27 -17
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +27 -17
- package/dist/index.mjs.map +2 -2
- package/dist/src/formatter.d.ts.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/formatter.test.ts +67 -6
- package/src/formatter.ts +29 -17
- package/src/types.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -6992,7 +6992,7 @@ function formatScalar(v) {
|
|
|
6992
6992
|
return "[" + v.map(formatScalar).join(SEP) + "]";
|
|
6993
6993
|
}
|
|
6994
6994
|
if (typeof v === "object") {
|
|
6995
|
-
return "{" + Object.entries(v).map(([key, value]) => `${key}: ${formatScalar(value)}`).join(SEP) + "}";
|
|
6995
|
+
return "{" + Object.entries(v).map(([key, value]) => `${isIdentifier(key) ? key : `"${key}"`}: ${formatScalar(value)}`).join(SEP) + "}";
|
|
6996
6996
|
}
|
|
6997
6997
|
return JSON.stringify(v);
|
|
6998
6998
|
}
|
|
@@ -7082,12 +7082,28 @@ function* formatNode(n, o = {}) {
|
|
|
7082
7082
|
yield* formatChildren(n, no);
|
|
7083
7083
|
break;
|
|
7084
7084
|
}
|
|
7085
|
+
case "image": {
|
|
7086
|
+
yield "!";
|
|
7087
|
+
yield "[";
|
|
7088
|
+
yield* formatValue(n.attributes.alt, no);
|
|
7089
|
+
yield "]";
|
|
7090
|
+
yield "(";
|
|
7091
|
+
yield* formatValue(n.attributes.src, no);
|
|
7092
|
+
if (n.attributes.title) {
|
|
7093
|
+
yield SPACE + `"${n.attributes.title}"`;
|
|
7094
|
+
}
|
|
7095
|
+
yield ")";
|
|
7096
|
+
break;
|
|
7097
|
+
}
|
|
7085
7098
|
case "link": {
|
|
7086
7099
|
yield "[";
|
|
7087
7100
|
yield* formatChildren(n, no);
|
|
7088
7101
|
yield "]";
|
|
7089
7102
|
yield "(";
|
|
7090
7103
|
yield* formatValue(n.attributes.href, no);
|
|
7104
|
+
if (n.attributes.title) {
|
|
7105
|
+
yield SPACE + `"${n.attributes.title}"`;
|
|
7106
|
+
}
|
|
7091
7107
|
yield ")";
|
|
7092
7108
|
break;
|
|
7093
7109
|
}
|
|
@@ -7113,16 +7129,6 @@ function* formatNode(n, o = {}) {
|
|
|
7113
7129
|
yield NL;
|
|
7114
7130
|
break;
|
|
7115
7131
|
}
|
|
7116
|
-
case "image": {
|
|
7117
|
-
yield "!";
|
|
7118
|
-
yield "[";
|
|
7119
|
-
yield* formatValue(n.attributes.alt, no);
|
|
7120
|
-
yield "]";
|
|
7121
|
-
yield "(";
|
|
7122
|
-
yield* formatValue(n.attributes.src, no);
|
|
7123
|
-
yield ")";
|
|
7124
|
-
break;
|
|
7125
|
-
}
|
|
7126
7132
|
case "fence": {
|
|
7127
7133
|
yield NL;
|
|
7128
7134
|
yield indent;
|
|
@@ -7133,8 +7139,7 @@ function* formatNode(n, o = {}) {
|
|
|
7133
7139
|
yield* formatAnnotations(n);
|
|
7134
7140
|
yield NL;
|
|
7135
7141
|
yield indent;
|
|
7136
|
-
yield n.attributes.content;
|
|
7137
|
-
yield indent;
|
|
7142
|
+
yield n.attributes.content.split(NL).join(NL + indent);
|
|
7138
7143
|
yield "```";
|
|
7139
7144
|
yield NL;
|
|
7140
7145
|
break;
|
|
@@ -7172,8 +7177,12 @@ function* formatNode(n, o = {}) {
|
|
|
7172
7177
|
break;
|
|
7173
7178
|
}
|
|
7174
7179
|
case "item": {
|
|
7175
|
-
|
|
7176
|
-
|
|
7180
|
+
for (let i = 0; i < n.children.length; i++) {
|
|
7181
|
+
const child = n.children[i];
|
|
7182
|
+
yield* formatValue(child, no);
|
|
7183
|
+
if (i === 0)
|
|
7184
|
+
yield* formatAnnotations(n);
|
|
7185
|
+
}
|
|
7177
7186
|
break;
|
|
7178
7187
|
}
|
|
7179
7188
|
case "strong": {
|
|
@@ -7266,10 +7275,11 @@ function* formatNode(n, o = {}) {
|
|
|
7266
7275
|
yield* formatChildren(n, no);
|
|
7267
7276
|
break;
|
|
7268
7277
|
}
|
|
7269
|
-
case "
|
|
7270
|
-
|
|
7278
|
+
case "comment": {
|
|
7279
|
+
yield "<!-- " + n.attributes.content + " -->\n";
|
|
7271
7280
|
break;
|
|
7272
7281
|
}
|
|
7282
|
+
case "error":
|
|
7273
7283
|
case "node":
|
|
7274
7284
|
break;
|
|
7275
7285
|
}
|