Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datocms-html-to-structured-text

Package Overview
Dependencies
Maintainers
5
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datocms-html-to-structured-text - npm Package Compare versions

Comparing version 1.2.1 to 1.2.3-alpha.0

2

dist/cjs/index.js

@@ -118,3 +118,3 @@ "use strict";

? options.allowedMarks
: datocms_structured_text_utils_1.allowedMarks,
: datocms_structured_text_utils_1.defaultMarks,
global: __assign({ baseUrl: null, baseUrlFound: false }, (options.shared || {})),

@@ -121,0 +121,0 @@ })];

@@ -57,3 +57,3 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

import documentToHast from 'hast-util-from-dom';
import { allowedMarks, } from 'datocms-structured-text-utils';
import { defaultMarks, } from 'datocms-structured-text-utils';
export function htmlToStructuredText(html, options) {

@@ -109,3 +109,3 @@ if (options === void 0) { options = {}; }

? options.allowedMarks
: allowedMarks,
: defaultMarks,
global: __assign({ baseUrl: null, baseUrlFound: false }, (options.shared || {})),

@@ -112,0 +112,0 @@ })];

{
"name": "datocms-html-to-structured-text",
"version": "1.2.1",
"version": "1.2.3-alpha.0",
"description": "Convert HTML (or a `hast` syntax tree) to a valid DatoCMS Structured Text `dast` document",

@@ -36,3 +36,3 @@ "keywords": [

"dependencies": {
"datocms-structured-text-utils": "^1.2.0",
"datocms-structured-text-utils": "^1.2.3-alpha.0",
"extend": "^3.0.2",

@@ -52,3 +52,3 @@ "hast-util-from-dom": "^3.0.0",

},
"gitHead": "f7a6bacaf5a517018a039c45a8dac35377ec6e13"
"gitHead": "a300eb72a078d572ec8e8bc4e53ff7d96dfe0529"
}

@@ -216,3 +216,3 @@ # `datocms-html-to-structured-text`

```js
import { findAll } from 'unist-utils-core';
import { visit } from 'unist-utils-core';

@@ -315,2 +315,4 @@ const html = `

```js
import { visit, CONTINUE } from 'unist-utils-core';
const html = `

@@ -323,11 +325,11 @@ <ul>

`;
const dast = await htmlToStructuredText(html, {
preprocess: (tree) => {
findAll(tree, (node, index, parent) => {
if (node.tagName === 'img') {
// Add the image to the root's children.
visit(tree, (node, index, parents) => {
if (node.tagName === 'img' && parents.length > 1) {
const parent = parents[parents.length - 1];
tree.children.push(node);
// remove the image from the parent's children array.
parent.children.splice(index, 1);
return;
return [CONTINUE, index];
}

@@ -340,5 +342,3 @@ });

const item = '123';
return createNode('block', {
item,
});
return createNode('block', { item });
},

@@ -345,0 +345,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc