Skip to content

Commit

Permalink
chore: sync
Browse files Browse the repository at this point in the history
  • Loading branch information
maxakuru committed Oct 21, 2024
2 parents 82fdd82 + 2c6dd83 commit 4a924a6
Show file tree
Hide file tree
Showing 8 changed files with 2,344 additions and 1,195 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [2.10.9](https://github.com/adobe/[secure]-html2md/compare/v2.10.8...v2.10.9) (2024-10-21)


### Bug Fixes

* **deps:** update dependency @adobe/[secure]-html-pipeline to v6.15.3 ([#575](https://github.com/adobe/[secure]-html2md/issues/575)) ([1afb3f6](https://github.com/adobe/[secure]-html2md/commit/1afb3f6db887ade532fbeef4e0bc9c545ba34857))

## [2.10.8](https://github.com/adobe/[secure]-html2md/compare/v2.10.7...v2.10.8) (2024-10-17)


### Bug Fixes

* properly handle sub/sup/u in divs without p ([#570](https://github.com/adobe/[secure]-html2md/issues/570)) ([97e6fba](https://github.com/adobe/[secure]-html2md/commit/97e6fbaac05fb3f14dad0b73128a632294f1fd78)), closes [#569](https://github.com/adobe/[secure]-html2md/issues/569)

## [2.10.7](https://github.com/adobe/[secure]-html2md/compare/v2.10.6...v2.10.7) (2024-10-14)


### Bug Fixes

* **deps:** update dependency hast-util-select to v6.0.3 ([#566](https://github.com/adobe/[secure]-html2md/issues/566)) ([641f4cd](https://github.com/adobe/[secure]-html2md/commit/641f4cdf04a50bf208cdec52b390ef207eceeb58))

## [2.10.6](https://github.com/adobe/[secure]-html2md/compare/v2.10.5...v2.10.6) (2024-09-28)


Expand Down
3,477 changes: 2,291 additions & 1,186 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/helix-html2md",
"version": "2.10.6",
"version": "2.10.9",
"private": true,
"description": "Helix Html2MD",
"main": "src/index.js",
Expand Down Expand Up @@ -49,14 +49,14 @@
"dependencies": {
"@adobe/fetch": "4.1.9",
"@adobe/helix-markdown-support": "7.1.6",
"@adobe/helix-mediahandler": "2.5.25",
"@adobe/helix-shared-body-data": "2.1.6",
"@adobe/helix-mediahandler": "2.5.27",
"@adobe/helix-shared-body-data": "2.1.7",
"@adobe/helix-shared-process-queue": "3.0.4",
"@adobe/helix-shared-utils": "3.0.2",
"@adobe/helix-shared-wrap": "2.0.2",
"@adobe/helix-status": "10.1.3",
"@adobe/remark-gridtables": "3.0.6",
"hast-util-select": "6.0.2",
"hast-util-select": "6.0.3",
"hast-util-to-mdast": "10.1.0",
"hast-util-to-string": "3.0.1",
"mdast-util-to-markdown": "2.1.0",
Expand All @@ -68,9 +68,10 @@
},
"devDependencies": {
"@adobe/eslint-config-helix": "2.0.8",
"@adobe/helix-deploy": "12.3.0",
"@adobe/helix-deploy": "12.3.2",
"@adobe/helix-html-pipeline": "^6.0.0",
"@adobe/helix-universal": "5.0.6",
"@adobe/helix-universal-devserver": "1.1.63",
"@adobe/semantic-release-coralogix": "1.1.32",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/exec": "6.0.3",
Expand All @@ -87,7 +88,7 @@
"mocha-suppress-logs": "0.5.1",
"nock": "13.5.5",
"nodemon": "3.1.7",
"semantic-release": "24.1.2"
"semantic-release": "24.1.3"
},
"lint-staged": {
"*.js": "eslint"
Expand Down
15 changes: 14 additions & 1 deletion src/html2md.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@adobe/helix-markdown-support';
import { remarkMatter } from '@adobe/helix-markdown-support/matter';
import remarkGridTable from '@adobe/remark-gridtables';
import { CONTINUE, visit } from 'unist-util-visit';
import { processImages } from './mdast-process-images.js';
import { processIcons } from './hast-process-icons.js';
import {
Expand Down Expand Up @@ -311,10 +312,21 @@ function handleBlockAsGridTable(state, node) {
function handleFormat(type) {
return (state, node) => {
const children = state.all(node);
return m(type, children);
// we wrap the special formats with 'strong' in order to let hast2mdast think it's flow content.
return m('strong', [m(type, children)], { virtual: true });
};
}

function cleanupFormats(tree) {
visit(tree, (node, index, parent) => {
if (node.type === 'strong' && node.virtual) {
// eslint-disable-next-line no-param-reassign,prefer-destructuring
parent.children[index] = node.children[0];
}
return CONTINUE;
});
}

export async function html2md(html, opts) {
const { log, url, mediaHandler } = opts;
const t0 = Date.now();
Expand Down Expand Up @@ -342,6 +354,7 @@ export async function html2md(html, opts) {
},
});

cleanupFormats(mdast);
addMetadata(hast, mdast);

await processImages(log, mdast, mediaHandler, url);
Expand Down
2 changes: 1 addition & 1 deletion test/dev/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import { DevelopmentServer } from '@adobe/helix-deploy';
import { DevelopmentServer } from '@adobe/helix-universal-devserver';
import { resolve } from 'path';
import { fileURLToPath } from 'url';

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/sub-sup-u.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ <h1>Sub / Sup / U Tests</h1>
<div><p>this is <u>underlined</u></p></div>
<div><p>this is <strong><sub>bold subscript</sub></strong></p></div>
<div><p>this is <u><em>italic underlined</em></u></p></div>
<div><p>this is <a href="#">a link with <sub>subscript</sub> inside</a>.</p></div>
<div><a href="#">A link with <sup>superscript</sup></a> inside but outside paragraph.</div>
<div><a href="#">e=mc<sup>2</sup></a></div>
</div>
</main>
</body>
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/sub-sup-u.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ this is <u>underlined</u>
this is **<sub>bold subscript</sub>**

this is _<u>italic underlined</u>_

this is [a link with <sub>subscript</sub> inside](#).

[A link with <sup>superscript</sup>](#) inside but outside paragraph.

[e=mc<sup>2</sup>](#)
2 changes: 1 addition & 1 deletion test/post-deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ And more...newcontent
+-------------------+-----------------------------------------+
| twitter:card | summary\\_large\\_image |
+-------------------+-----------------------------------------+
| serp-content-type | product |
| serp-content-type | overlay |
+-------------------+-----------------------------------------+
`;

Expand Down

0 comments on commit 4a924a6

Please sign in to comment.