@markdoc/markdoc 0.2.0 → 0.2.2
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 +14 -9
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +14 -9
- package/dist/index.mjs.map +2 -2
- package/dist/react.js +1 -1
- package/dist/react.js.map +2 -2
- package/dist/src/formatter.d.ts.map +1 -1
- package/package.json +7 -3
- package/src/formatter.test.ts +43 -20
- package/src/formatter.ts +23 -11
- package/src/tag.test.ts +17 -0
- package/src/tag.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6654,7 +6654,7 @@ var Tag = class {
|
|
|
6654
6654
|
}
|
|
6655
6655
|
};
|
|
6656
6656
|
Tag.isTag = (tag) => {
|
|
6657
|
-
return
|
|
6657
|
+
return !!(tag?.$$mdtype === "Tag");
|
|
6658
6658
|
};
|
|
6659
6659
|
|
|
6660
6660
|
// src/schema-types/class.ts
|
|
@@ -6962,6 +6962,7 @@ var NL = "\n";
|
|
|
6962
6962
|
var OL = "1. ";
|
|
6963
6963
|
var UL = "- ";
|
|
6964
6964
|
var MAX_TAG_OPENING_WIDTH = 80;
|
|
6965
|
+
var WRAPPING_TYPES = ["strong", "em", "s"];
|
|
6965
6966
|
var max = (a, b) => Math.max(a, b);
|
|
6966
6967
|
var increment = (o, n = 2) => ({
|
|
6967
6968
|
...o,
|
|
@@ -6983,7 +6984,7 @@ function formatScalar(v) {
|
|
|
6983
6984
|
return format(v);
|
|
6984
6985
|
}
|
|
6985
6986
|
if (v === null) {
|
|
6986
|
-
return "";
|
|
6987
|
+
return "null";
|
|
6987
6988
|
}
|
|
6988
6989
|
if (Array.isArray(v)) {
|
|
6989
6990
|
return "[" + v.map(formatScalar).join(SEP) + "]";
|
|
@@ -7111,18 +7112,22 @@ function* formatNode(n, o = {}) {
|
|
|
7111
7112
|
}
|
|
7112
7113
|
case "text": {
|
|
7113
7114
|
const { content } = n.attributes;
|
|
7114
|
-
if (ast_default.isAst(content))
|
|
7115
|
+
if (ast_default.isAst(content)) {
|
|
7115
7116
|
yield OPEN + SPACE;
|
|
7116
|
-
|
|
7117
|
-
if (ast_default.isAst(content))
|
|
7117
|
+
yield* formatValue(content, no);
|
|
7118
7118
|
yield SPACE + CLOSE;
|
|
7119
|
+
} else {
|
|
7120
|
+
if (o.parent && WRAPPING_TYPES.includes(o.parent.type)) {
|
|
7121
|
+
yield* escapeMarkdownCharacters(content, /[*_~]/g);
|
|
7122
|
+
} else {
|
|
7123
|
+
yield* escapeMarkdownCharacters(content, /^[*>#]/);
|
|
7124
|
+
}
|
|
7125
|
+
}
|
|
7119
7126
|
break;
|
|
7120
7127
|
}
|
|
7121
7128
|
case "blockquote": {
|
|
7122
|
-
|
|
7123
|
-
yield indent;
|
|
7124
|
-
yield "> ";
|
|
7125
|
-
yield* trimStart(formatChildren(n, no));
|
|
7129
|
+
const prefix = ">" + SPACE;
|
|
7130
|
+
yield n.children.map((child) => format(child, no).trimStart()).map((d) => NL + indent + prefix + d).join(indent + prefix);
|
|
7126
7131
|
break;
|
|
7127
7132
|
}
|
|
7128
7133
|
case "hr": {
|