ag-common 0.0.676 → 0.0.678
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.
|
@@ -6,20 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Markdown = void 0;
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const common_1 = require("../../../common");
|
|
9
10
|
const array_1 = require("../../../common/helpers/array");
|
|
10
11
|
const trim_1 = require("../../../common/helpers/string/trim");
|
|
11
|
-
const injectTable = ({ tableRows, preprocessText, }) => {
|
|
12
|
-
|
|
13
|
-
react_1.default.createElement("
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}))));
|
|
22
|
-
};
|
|
12
|
+
const injectTable = ({ tableRows, preprocessText, }) => (react_1.default.createElement("table", { key: (0, common_1.hashCode)(JSON.stringify(tableRows)) },
|
|
13
|
+
react_1.default.createElement("thead", null,
|
|
14
|
+
react_1.default.createElement("tr", null, tableRows[0]
|
|
15
|
+
.split('|')
|
|
16
|
+
.map((header) => header.trim())
|
|
17
|
+
.map((header) => (react_1.default.createElement("th", { key: header }, preprocessText(header)))))),
|
|
18
|
+
react_1.default.createElement("tbody", null, tableRows.slice(2).map((row) => {
|
|
19
|
+
const cells = row.split('|').map((cell) => cell.trim());
|
|
20
|
+
return (react_1.default.createElement("tr", { key: row }, cells.map((cell) => (react_1.default.createElement("td", { key: cell }, preprocessText(cell))))));
|
|
21
|
+
}))));
|
|
23
22
|
const injectGroup = ({ output, pos, wrap, }) => {
|
|
24
23
|
const outputEndIndex = output.length;
|
|
25
24
|
const sum = [];
|
|
@@ -40,11 +39,12 @@ function renderMarkdown({ markdown, preprocessText = (s) => s, }) {
|
|
|
40
39
|
let a = -1;
|
|
41
40
|
do {
|
|
42
41
|
a += 1;
|
|
43
|
-
const line = (_a = lines
|
|
42
|
+
const line = (_a = lines[a]) !== null && _a !== void 0 ? _a : '';
|
|
43
|
+
const la = line + a;
|
|
44
44
|
const star = /\*\*(.*?)\*\*/gim;
|
|
45
45
|
//handle inline **s
|
|
46
46
|
if (line.match(star)) {
|
|
47
|
-
output.push(react_1.default.createElement("p", { key:
|
|
47
|
+
output.push(react_1.default.createElement("p", { key: la, dangerouslySetInnerHTML: {
|
|
48
48
|
__html: line.replace(star, `<b>$1</b>`).trim(),
|
|
49
49
|
} }));
|
|
50
50
|
continue;
|
|
@@ -115,20 +115,20 @@ function renderMarkdown({ markdown, preprocessText = (s) => s, }) {
|
|
|
115
115
|
else if (line.startsWith('*') || line.startsWith('-')) {
|
|
116
116
|
const t = line.slice(2).trim();
|
|
117
117
|
if (t.length > 0) {
|
|
118
|
-
output.push(react_1.default.createElement("li",
|
|
118
|
+
output.push(react_1.default.createElement("li", { key: t }, preprocessText(t)));
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
//ol - li
|
|
122
122
|
else if (line.match(/^[0-9]+\./gim)) {
|
|
123
123
|
const t = line.slice(3).trim();
|
|
124
124
|
if (t.length > 0) {
|
|
125
|
-
output.push(react_1.default.createElement("li", { key:
|
|
125
|
+
output.push(react_1.default.createElement("li", { key: t }, preprocessText(t)));
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
//text
|
|
129
129
|
else {
|
|
130
130
|
if (line.length > 0) {
|
|
131
|
-
output.push(react_1.default.createElement("p", { key:
|
|
131
|
+
output.push(react_1.default.createElement("p", { key: la }, preprocessText(line)));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
} while (a < lines.length);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.678",
|
|
3
3
|
"name": "ag-common",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@types/react": "18.2.67",
|
|
61
61
|
"@types/react-dom": "18.2.22",
|
|
62
62
|
"cross-env": "7.0.3",
|
|
63
|
-
"eslint-config-e7npm": "0.0.
|
|
63
|
+
"eslint-config-e7npm": "0.0.94",
|
|
64
64
|
"globstar": "1.0.0",
|
|
65
65
|
"rimraf": "5.0.5",
|
|
66
66
|
"storybook": "8.0.4",
|