@adobe/helix-docx2md 1.4.9 → 1.4.10
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.4.10](https://github.com/adobe/helix-docx2md/compare/v1.4.9...v1.4.10) (2023-07-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improve handling of sub- and superscript ([#266](https://github.com/adobe/helix-docx2md/issues/266)) ([fd32fc8](https://github.com/adobe/helix-docx2md/commit/fd32fc8bcaabe1f591c5ba488abc7a21a37e4f1b)), closes [#262](https://github.com/adobe/helix-docx2md/issues/262)
|
|
7
|
+
|
|
1
8
|
## [1.4.9](https://github.com/adobe/helix-docx2md/compare/v1.4.8...v1.4.9) (2023-07-10)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-docx2md",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.10",
|
|
4
4
|
"description": "Helix library that converts word documents to markdown",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/adobe/helix-docx2md#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@adobe/helix-markdown-support": "6.1
|
|
36
|
+
"@adobe/helix-markdown-support": "6.2.1",
|
|
37
37
|
"@adobe/helix-shared-process-queue": "3.0.0",
|
|
38
38
|
"@adobe/mammoth": "1.5.1-bleeding.2",
|
|
39
39
|
"@adobe/mdast-util-gridtables": "2.0.1",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@adobe/eslint-config-helix": "2.0.2",
|
|
55
|
-
"@adobe/helix-mediahandler": "2.2.
|
|
55
|
+
"@adobe/helix-mediahandler": "2.2.5",
|
|
56
56
|
"@semantic-release/changelog": "6.0.3",
|
|
57
57
|
"@semantic-release/exec": "6.0.3",
|
|
58
58
|
"@semantic-release/git": "10.0.1",
|
|
59
59
|
"c8": "8.0.0",
|
|
60
60
|
"dotenv": "16.3.1",
|
|
61
|
-
"eslint": "8.
|
|
61
|
+
"eslint": "8.45.0",
|
|
62
62
|
"husky": "8.0.3",
|
|
63
63
|
"junit-report-builder": "3.0.1",
|
|
64
64
|
"lint-staged": "13.2.3",
|
|
@@ -63,13 +63,13 @@ export default function run(h, node, parent, siblings) {
|
|
|
63
63
|
|
|
64
64
|
let result = nodes;
|
|
65
65
|
if (node.verticalAlignment === 'superscript') {
|
|
66
|
-
result = [h('
|
|
66
|
+
result = [h('superscript', result)];
|
|
67
67
|
}
|
|
68
68
|
if (node.verticalAlignment === 'subscript') {
|
|
69
|
-
result = [h('
|
|
69
|
+
result = [h('subscript', result)];
|
|
70
70
|
}
|
|
71
71
|
if (node.isUnderline && node.styleId !== 'Hyperlink') {
|
|
72
|
-
result = [h('
|
|
72
|
+
result = [h('underline', result)];
|
|
73
73
|
}
|
|
74
74
|
if (node.isBold) {
|
|
75
75
|
result = [h('strong', result)];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import toMarkdown from './to-markdown.js';
|
|
13
|
+
|
|
14
|
+
export default function formatPlugin(options) {
|
|
15
|
+
const data = this.data();
|
|
16
|
+
|
|
17
|
+
function add(field, value) {
|
|
18
|
+
/* c8 ignore next 2 */
|
|
19
|
+
if (data[field]) {
|
|
20
|
+
data[field].push(value);
|
|
21
|
+
} else {
|
|
22
|
+
data[field] = [value];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// add('micromarkExtensions', syntax(options));
|
|
27
|
+
// add('fromMarkdownExtensions', fromMarkdown(options));
|
|
28
|
+
add('toMarkdownExtensions', toMarkdown(options));
|
|
29
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Renders special html only format.
|
|
14
|
+
*/
|
|
15
|
+
function format(tagName) {
|
|
16
|
+
const tagOpen = `<${tagName}>`;
|
|
17
|
+
const tagClose = `</${tagName}>`;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {Node} node
|
|
21
|
+
* @param {Parents | undefined} _
|
|
22
|
+
* @param {State} state
|
|
23
|
+
* @param {Info} info
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
return (node, _, state, info) => {
|
|
27
|
+
const exit = state.enter('html');
|
|
28
|
+
const tracker = state.createTracker(info);
|
|
29
|
+
let value = tracker.move(tagOpen);
|
|
30
|
+
value += tracker.move(
|
|
31
|
+
state.containerPhrasing(node, {
|
|
32
|
+
before: value,
|
|
33
|
+
after: tagOpen,
|
|
34
|
+
...tracker.current(),
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
value += tracker.move(tagClose);
|
|
38
|
+
exit();
|
|
39
|
+
return value;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default function toMarkdown() {
|
|
44
|
+
return {
|
|
45
|
+
handlers: {
|
|
46
|
+
subscript: format('sub'),
|
|
47
|
+
superscript: format('sup'),
|
|
48
|
+
underline: format('u'),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
package/src/mdast2md/mdast2md.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
sanitizeText,
|
|
27
27
|
sanitizeTextAndFormats,
|
|
28
28
|
sanitizeLinks,
|
|
29
|
-
imageReferences,
|
|
29
|
+
imageReferences, renderHtmlFormats,
|
|
30
30
|
} from '@adobe/helix-markdown-support';
|
|
31
31
|
import { remarkMatter } from '@adobe/helix-markdown-support/matter';
|
|
32
32
|
import remarkGridTable from '@adobe/remark-gridtables';
|
|
@@ -34,6 +34,7 @@ import remarkGridTable from '@adobe/remark-gridtables';
|
|
|
34
34
|
import processImages from './mdast-process-images.js';
|
|
35
35
|
import sanitizeAutoEmbeds from './mdast-sanitize-autoembeds.js';
|
|
36
36
|
import orderedListPlugin from './ordered-list/index.js';
|
|
37
|
+
import formatPlugin from './format-plugin/index.js';
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Converts the mdast to markdown using common filters suitable for helix.
|
|
@@ -61,6 +62,7 @@ export default async function mdast2md(mdast, opts = {}) {
|
|
|
61
62
|
ruleSpaces: false,
|
|
62
63
|
})
|
|
63
64
|
.use(gfm)
|
|
65
|
+
.use(formatPlugin)
|
|
64
66
|
.use(remarkMatter)
|
|
65
67
|
.use(orderedListPlugin);
|
|
66
68
|
|
|
@@ -81,6 +83,7 @@ export default async function mdast2md(mdast, opts = {}) {
|
|
|
81
83
|
await sanitizeFormats(mdast); // collapse formats once
|
|
82
84
|
await sanitizeLinks(mdast);
|
|
83
85
|
await sanitizeFormats(mdast); // and again for sanitized links
|
|
86
|
+
await renderHtmlFormats(mdast);
|
|
84
87
|
await sanitizeText(mdast);
|
|
85
88
|
await suppressSpaceCode(mdast);
|
|
86
89
|
await sanitizeAutoEmbeds(mdast);
|