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
1
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 0.1.0-alpha.17 to 0.1.0-alpha.18

53

dist/lib/index.js
"use strict";
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -63,3 +44,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

Object.defineProperty(exports, "__esModule", { value: true });
exports.toDast = exports.htmlToDast = void 0;
exports.hastToDast = exports.parse5ToDast = exports.htmlToDast = void 0;
// @ts-ignore

@@ -69,16 +50,15 @@ var rehype_minify_whitespace_1 = __importDefault(require("rehype-minify-whitespace"));

var handlers_1 = require("./lib/handlers");
var hast_util_from_parse5_1 = __importDefault(require("hast-util-from-parse5"));
var hast_util_from_dom_1 = __importDefault(require("hast-util-from-dom"));
function htmlToDast(html, settings) {
if (settings === void 0) { settings = {}; }
return __awaiter(this, void 0, void 0, function () {
var mode, parseHtml, tree;
var document, tree;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
mode = typeof DOMParser !== 'undefined' ? 'dom' : 'node';
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./lib/parse." + mode)); })];
case 1:
parseHtml = (_a.sent()).parseHtml;
tree = parseHtml(html);
return [2 /*return*/, toDast(tree, settings)];
if (typeof DOMParser === 'undefined') {
throw new Error('DOMParser is not available. Consider using `parse5ToDast` instead!');
}
document = new DOMParser().parseFromString(html, 'text/html');
tree = hast_util_from_dom_1.default(document);
return [2 /*return*/, hastToDast(tree, settings)];
});

@@ -88,5 +68,16 @@ });

exports.htmlToDast = htmlToDast;
function toDast(tree, settings) {
function parse5ToDast(document, settings) {
if (settings === void 0) { settings = {}; }
return __awaiter(this, void 0, void 0, function () {
var tree;
return __generator(this, function (_a) {
tree = hast_util_from_parse5_1.default(document);
return [2 /*return*/, hastToDast(tree, settings)];
});
});
}
exports.parse5ToDast = parse5ToDast;
function hastToDast(tree, settings) {
if (settings === void 0) { settings = {}; }
return __awaiter(this, void 0, void 0, function () {
var createNode;

@@ -113,3 +104,3 @@ return __generator(this, function (_a) {

}
exports.toDast = toDast;
exports.hastToDast = hastToDast;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

import { Node, CreateNodeFunction, HastRootNode } from './lib/types';
import { Root, CreateNodeFunction, HastRootNode } from './lib/types';
import parse5 from '@types/parse5';
export declare type Settings = Partial<{

@@ -6,3 +7,4 @@ newlines: boolean;

}>;
export declare function htmlToDast(html: string, settings?: Settings): Promise<Node>;
export declare function toDast(tree: HastRootNode, settings?: Settings): Promise<Node>;
export declare function htmlToDast(html: string, settings?: Settings): Promise<Root>;
export declare function parse5ToDast(document: parse5.Document, settings?: Settings): Promise<Root>;
export declare function hastToDast(tree: HastRootNode, settings?: Settings): Promise<Root>;

@@ -1,3 +0,3 @@

import { Node, NodeType, Mark } from 'datocms-structured-text-utils';
export { Node, NodeType, Mark };
import { Node, Root, NodeType, Mark } from 'datocms-structured-text-utils';
export { Node, Root, NodeType, Mark };
export declare type CreateNodeFunction = (type: NodeType, props: Omit<Node, 'type'>) => Node;

@@ -4,0 +4,0 @@ export interface Context {

{
"name": "datocms-html-to-structured-text",
"version": "0.1.0-alpha.17",
"version": "0.1.0-alpha.18",
"description": "Convert HTML (or Hast syntax tree) to a valid DatoCMS Structured Text Dast document",

@@ -41,3 +41,2 @@ "keywords": [

"hast-util-to-text": "^2.0.1",
"parse5": "^6.0.1",
"rehype-minify-whitespace": "^4.0.5",

@@ -47,5 +46,6 @@ "unist-util-is": "^4.0.4"

"devDependencies": {
"parse5": "^6.0.1",
"unist-utils-core": "^1.0.5"
},
"gitHead": "67c03de2e3ef8194b8c3ca8bcccf3ee0f74f3b50"
"gitHead": "0673d3d0fa432d6611c99172b12107daa93dc325"
}

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