@honkit/markup-it 4.0.0 → 4.0.6
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/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honkit/markup-it",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.6",
|
|
4
4
|
"description": "Pipeline for working with markup input (for example Markdown)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"draft-js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"url": "git+https://github.com/GitbookIO/draft-markup.git"
|
|
18
18
|
},
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
|
-
"author": "
|
|
20
|
+
"author": "azu",
|
|
21
21
|
"main": "lib/index.js",
|
|
22
22
|
"files": [
|
|
23
23
|
"lib",
|
|
@@ -37,21 +37,19 @@
|
|
|
37
37
|
"htmlparser2": "^4.1.0",
|
|
38
38
|
"immutable": "^3.7.6",
|
|
39
39
|
"is": "^3.3.0",
|
|
40
|
-
"ltrim": "^1.0.0",
|
|
41
40
|
"object-values": "^2.0.0",
|
|
42
|
-
"range-utils": "^1.1.0"
|
|
43
|
-
"rtrim": "^1.0.0"
|
|
41
|
+
"range-utils": "^1.1.0"
|
|
44
42
|
},
|
|
45
43
|
"devDependencies": {
|
|
46
|
-
"eslint": "^
|
|
47
|
-
"jest": "^
|
|
48
|
-
"jsdom": "^
|
|
44
|
+
"eslint": "^8.23.1",
|
|
45
|
+
"jest": "^29.0.3",
|
|
46
|
+
"jsdom": "^20.0.0",
|
|
49
47
|
"rimraf": "^3.0.2",
|
|
50
48
|
"should": "^13.2.3",
|
|
51
|
-
"ts-jest": "^
|
|
49
|
+
"ts-jest": "^29.0.1"
|
|
52
50
|
},
|
|
53
51
|
"publishConfig": {
|
|
54
52
|
"access": "public"
|
|
55
53
|
},
|
|
56
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "7fad871e16ce09d49d6c9a17d695b6259671d95d"
|
|
57
55
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { normalizeTeX } = require("../math.js");
|
|
2
|
+
|
|
3
|
+
describe("normalizeTeX", () => {
|
|
4
|
+
it(`should normalize`, () => {
|
|
5
|
+
expect(normalizeTeX("$a$", true)).toMatchInlineSnapshot(`"$a$"`);
|
|
6
|
+
expect(normalizeTeX("$$a$$", true)).toMatchInlineSnapshot(`"$$a$$"`);
|
|
7
|
+
expect(normalizeTeX("$a$ $b$", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
8
|
+
expect(normalizeTeX("$a$ $b$ $c$", true)).toMatchInlineSnapshot(`"$a$ $b$ $c$"`);
|
|
9
|
+
expect(normalizeTeX("$a$\n$b$", true)).toMatchInlineSnapshot(`
|
|
10
|
+
"$a$
|
|
11
|
+
$b$"
|
|
12
|
+
`);
|
|
13
|
+
expect(normalizeTeX("$a$\n\n$b$", true)).toMatchInlineSnapshot(`
|
|
14
|
+
"$a$
|
|
15
|
+
|
|
16
|
+
$b$"
|
|
17
|
+
`);
|
|
18
|
+
expect(normalizeTeX("$a$ $b$\n", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
19
|
+
expect(normalizeTeX("$a$ $b$\n\n", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
20
|
+
expect(normalizeTeX("$a$\n$b$\n", true)).toMatchInlineSnapshot(`
|
|
21
|
+
"$a$
|
|
22
|
+
$b$"
|
|
23
|
+
`);
|
|
24
|
+
expect(normalizeTeX("$a$\n\n$b$\n\n", true)).toMatchInlineSnapshot(`
|
|
25
|
+
"$a$
|
|
26
|
+
|
|
27
|
+
$b$"
|
|
28
|
+
`);
|
|
29
|
+
expect(normalizeTeX("$a$ $b$", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
30
|
+
expect(normalizeTeX("$a$ $b$", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
31
|
+
expect(normalizeTeX("$a$ $b$ $c$", true)).toMatchInlineSnapshot(`"$a$ $b$ $c$"`);
|
|
32
|
+
expect(normalizeTeX("$a$ $b$ $c$", true)).toMatchInlineSnapshot(`"$a$ $b$ $c$"`);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
const ltrim = require("ltrim");
|
|
2
|
-
const rtrim = require("rtrim");
|
|
3
|
-
|
|
4
1
|
const reInline = require("./re/inline");
|
|
5
2
|
const MarkupIt = require("../../");
|
|
6
3
|
|
|
@@ -18,16 +15,15 @@ function isInlineTex(content) {
|
|
|
18
15
|
* @return {String}
|
|
19
16
|
*/
|
|
20
17
|
function normalizeTeX(content, isInline) {
|
|
21
|
-
|
|
22
|
-
content =
|
|
23
|
-
|
|
18
|
+
// trim new line at start and end, but preserve spaces
|
|
19
|
+
content = content.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
20
|
+
|
|
24
21
|
if (!isInline) {
|
|
25
22
|
content = `\n${content}\n`;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
return content;
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
module.exports = MarkupIt.Rule(MarkupIt.ENTITIES.MATH)
|
|
32
28
|
.regExp(reInline.math, (state, match) => {
|
|
33
29
|
const text = match[1];
|
|
@@ -57,3 +53,4 @@ module.exports = MarkupIt.Rule(MarkupIt.ENTITIES.MATH)
|
|
|
57
53
|
|
|
58
54
|
return output;
|
|
59
55
|
});
|
|
56
|
+
module.exports.normalizeTeX = normalizeTeX;
|