Socket
Socket
Sign inDemoInstall

@tryghost/kg-parser-plugins

Package Overview
Dependencies
Maintainers
15
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tryghost/kg-parser-plugins - npm Package Compare versions

Comparing version 1.0.10 to 1.1.0

33

cjs/parser-plugins.js

@@ -508,2 +508,34 @@ 'use strict';

// Nested paragraphs in blockquote are currently treated as separate blockquotes,
// see [here](https://github.com/bustle/mobiledoc-kit/issues/715). When running migrations,
// this is not the desired behaviour and will cause the content to lose the previous semantic.
function blockquoteWithChildren(node) {
if (node.nodeType !== 1 || node.tagName !== 'BLOCKQUOTE' || node.children.length < 1) {
return;
}
const html = [];
const children = Array.from(node.children);
children.forEach((child) => {
let nextSibling = child.nextSibling;
let previousSibling = child.previousSibling;
// Only add a soft-break for two sequential paragraphs.
// Use the innerHTML only in that case, so Mobiledoc's default behaviour
// of creating separate blockquotes doesn't apply.
if (child.tagName === 'P' && (nextSibling && nextSibling.tagName === 'P')) {
html.push(`${child.innerHTML}<br><br>`);
} else if (child.tagName === 'P' && (previousSibling && previousSibling.tagName === 'P')) {
html.push(child.innerHTML);
} else {
html.push(child.outerHTML);
}
});
node.innerHTML = html.join('').trim();
return;
}
function tableToHtmlCard(node, builder, {addSection, nodeFinished}) {

@@ -527,2 +559,3 @@ if (node.nodeType !== 1 || node.tagName !== 'TABLE') {

kgHtmlCardToCard,
blockquoteWithChildren,
brToSoftBreakAtom,

@@ -529,0 +562,0 @@ removeLeadingNewline,

30

es/parser-plugins.js

@@ -544,2 +544,30 @@ import cleanBasicHtml from '@tryghost/kg-clean-basic-html';

nodeFinished();
} // Nested paragraphs in blockquote are currently treated as separate blockquotes,
// see [here](https://github.com/bustle/mobiledoc-kit/issues/715). When running migrations,
// this is not the desired behaviour and will cause the content to lose the previous semantic.
function blockquoteWithChildren(node) {
if (node.nodeType !== 1 || node.tagName !== 'BLOCKQUOTE' || node.children.length < 1) {
return;
}
const html = [];
const children = Array.from(node.children);
children.forEach(child => {
let nextSibling = child.nextSibling;
let previousSibling = child.previousSibling; // Only add a soft-break for two sequential paragraphs.
// Use the innerHTML only in that case, so Mobiledoc's default behaviour
// of creating separate blockquotes doesn't apply.
if (child.tagName === 'P' && nextSibling && nextSibling.tagName === 'P') {
html.push(`${child.innerHTML}<br><br>`);
} else if (child.tagName === 'P' && previousSibling && previousSibling.tagName === 'P') {
html.push(child.innerHTML);
} else {
html.push(child.outerHTML);
}
});
node.innerHTML = html.join('').trim();
return;
}

@@ -567,3 +595,3 @@

return [mixtapeEmbed, kgHtmlCardToCard, brToSoftBreakAtom, removeLeadingNewline, kgGalleryCardToCard, figureBlockquoteToEmbedCard, // I think these can contain images
return [mixtapeEmbed, kgHtmlCardToCard, blockquoteWithChildren, brToSoftBreakAtom, removeLeadingNewline, kgGalleryCardToCard, figureBlockquoteToEmbedCard, // I think these can contain images
grafGalleryToCard, sqsGalleriesToCard, figureToImageCard, imgToCard, hrToCard, figureToCodeCard, preCodeToCard, figureIframeToEmbedCard, iframeToEmbedCard, // Process iFrames without figures after ones with

@@ -570,0 +598,0 @@ figureScriptToHtmlCard, tableToHtmlCard];

@@ -513,2 +513,34 @@ /* global DOMParser, window */

// Nested paragraphs in blockquote are currently treated as separate blockquotes,
// see [here](https://github.com/bustle/mobiledoc-kit/issues/715). When running migrations,
// this is not the desired behaviour and will cause the content to lose the previous semantic.
function blockquoteWithChildren(node) {
if (node.nodeType !== 1 || node.tagName !== 'BLOCKQUOTE' || node.children.length < 1) {
return;
}
const html = [];
const children = Array.from(node.children);
children.forEach((child) => {
let nextSibling = child.nextSibling;
let previousSibling = child.previousSibling;
// Only add a soft-break for two sequential paragraphs.
// Use the innerHTML only in that case, so Mobiledoc's default behaviour
// of creating separate blockquotes doesn't apply.
if (child.tagName === 'P' && (nextSibling && nextSibling.tagName === 'P')) {
html.push(`${child.innerHTML}<br><br>`);
} else if (child.tagName === 'P' && (previousSibling && previousSibling.tagName === 'P')) {
html.push(child.innerHTML);
} else {
html.push(child.outerHTML);
}
});
node.innerHTML = html.join('').trim();
return;
}
function tableToHtmlCard(node, builder, {addSection, nodeFinished}) {

@@ -532,2 +564,3 @@ if (node.nodeType !== 1 || node.tagName !== 'TABLE') {

kgHtmlCardToCard,
blockquoteWithChildren,
brToSoftBreakAtom,

@@ -534,0 +567,0 @@ removeLeadingNewline,

16

package.json
{
"name": "@tryghost/kg-parser-plugins",
"version": "1.0.10",
"version": "1.1.0",
"repository": "https://github.com/TryGhost/Koenig/tree/master/packages/kg-parser-plugins",

@@ -33,16 +33,16 @@ "author": "Ghost Foundation",

"devDependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"@babel/core": "7.12.10",
"@babel/preset-env": "7.12.11",
"@tryghost/mobiledoc-kit": "0.11.2-ghost.4",
"jsdom": "16.4.0",
"mocha": "8.2.0",
"rollup": "2.33.1",
"mocha": "8.2.1",
"rollup": "2.36.1",
"rollup-plugin-babel": "4.4.0",
"should": "13.2.3",
"sinon": "9.2.1"
"sinon": "9.2.3"
},
"dependencies": {
"@tryghost/kg-clean-basic-html": "^1.0.10"
"@tryghost/kg-clean-basic-html": "^1.0.11"
},
"gitHead": "44d0c6d7a156baf54f973c44c208ae4791e3eff7"
"gitHead": "12f556f73291e951ce9cd95e37d7186162e341c1"
}

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