Socket
Socket
Sign inDemoInstall

@tryghost/kg-parser-plugins

Package Overview
Dependencies
Maintainers
11
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.2 to 0.5.0

30

cjs/parser-plugins.js

@@ -28,2 +28,31 @@ 'use strict';

// https://github.com/TryGhost/Koenig/issues/1
// allows arbitrary HTML blocks wrapped in our card comments to be extracted
// into a HTML card rather than being put through the normal parse+plugins
function kgHtmlCardToCard(node, builder, {addSection, nodeFinished}) {
if (node.nodeType !== 8 || node.nodeValue !== 'kg-card-begin: html') {
return;
}
let html = [];
function isHtmlEndComment(node) {
return node && node.nodeType === 8 && node.nodeValue === 'kg-card-end: html';
}
let nextNode = node.nextSibling;
while (nextNode && !isHtmlEndComment(nextNode)) {
let currentNode = nextNode;
html.push(currentNode.outerHTML);
nextNode = currentNode.nextSibling;
// remove nodes as we go so that they don't go through the parser
currentNode.remove();
}
let payload = {html: html.join('\n').trim()};
let cardSection = builder.createCardSection('html', payload);
addSection(cardSection);
nodeFinished();
}
// mobiledoc by default ignores <BR> tags but we have a custom SoftReturn atom

@@ -171,2 +200,3 @@ function brToSoftBreakAtom(node, builder, {addMarkerable, nodeFinished}) {

return [
kgHtmlCardToCard,
brToSoftBreakAtom,

@@ -173,0 +203,0 @@ removeLeadingNewline,

39

es/parser-plugins.js

@@ -20,5 +20,40 @@ import cleanBasicHtml from '@tryghost/kg-clean-basic-html';

} // PLUGINS -----------------------------------------------------------------
// mobiledoc by default ignores <BR> tags but we have a custom SoftReturn atom
// https://github.com/TryGhost/Koenig/issues/1
// allows arbitrary HTML blocks wrapped in our card comments to be extracted
// into a HTML card rather than being put through the normal parse+plugins
function kgHtmlCardToCard(node, builder, {
addSection,
nodeFinished
}) {
if (node.nodeType !== 8 || node.nodeValue !== 'kg-card-begin: html') {
return;
}
let html = [];
function isHtmlEndComment(node) {
return node && node.nodeType === 8 && node.nodeValue === 'kg-card-end: html';
}
let nextNode = node.nextSibling;
while (nextNode && !isHtmlEndComment(nextNode)) {
let currentNode = nextNode;
html.push(currentNode.outerHTML);
nextNode = currentNode.nextSibling; // remove nodes as we go so that they don't go through the parser
currentNode.remove();
}
let payload = {
html: html.join('\n').trim()
};
let cardSection = builder.createCardSection('html', payload);
addSection(cardSection);
nodeFinished();
} // mobiledoc by default ignores <BR> tags but we have a custom SoftReturn atom
function brToSoftBreakAtom(node, builder, {

@@ -181,3 +216,3 @@ addMarkerable,

return [brToSoftBreakAtom, removeLeadingNewline, figureToImageCard, imgToCard, hrToCard, figureToCodeCard, preCodeToCard];
return [kgHtmlCardToCard, brToSoftBreakAtom, removeLeadingNewline, figureToImageCard, imgToCard, hrToCard, figureToCodeCard, preCodeToCard];
}

@@ -184,0 +219,0 @@

@@ -33,2 +33,31 @@ /* global DOMParser, window */

// https://github.com/TryGhost/Koenig/issues/1
// allows arbitrary HTML blocks wrapped in our card comments to be extracted
// into a HTML card rather than being put through the normal parse+plugins
function kgHtmlCardToCard(node, builder, {addSection, nodeFinished}) {
if (node.nodeType !== 8 || node.nodeValue !== 'kg-card-begin: html') {
return;
}
let html = [];
function isHtmlEndComment(node) {
return node && node.nodeType === 8 && node.nodeValue === 'kg-card-end: html';
}
let nextNode = node.nextSibling;
while (nextNode && !isHtmlEndComment(nextNode)) {
let currentNode = nextNode;
html.push(currentNode.outerHTML);
nextNode = currentNode.nextSibling;
// remove nodes as we go so that they don't go through the parser
currentNode.remove();
}
let payload = {html: html.join('\n').trim()};
let cardSection = builder.createCardSection('html', payload);
addSection(cardSection);
nodeFinished();
}
// mobiledoc by default ignores <BR> tags but we have a custom SoftReturn atom

@@ -176,2 +205,3 @@ function brToSoftBreakAtom(node, builder, {addMarkerable, nodeFinished}) {

return [
kgHtmlCardToCard,
brToSoftBreakAtom,

@@ -178,0 +208,0 @@ removeLeadingNewline,

6

package.json
{
"name": "@tryghost/kg-parser-plugins",
"version": "0.4.2",
"version": "0.5.0",
"repository": "https://github.com/TryGhost/Ghost-SDK/tree/master/packages/kg-parser-plugins",

@@ -32,3 +32,3 @@ "author": "Ghost Foundation",

"@babel/preset-env": "7.4.4",
"@tryghost/mobiledoc-kit": "0.11.2-ghost.2",
"@tryghost/mobiledoc-kit": "0.11.2-ghost.3",
"jsdom": "15.0.0",

@@ -44,3 +44,3 @@ "mocha": "5.2.0",

},
"gitHead": "709dbeab6eb05c6724946ba17fa40c9cb7523da3"
"gitHead": "864650f87f0552ba899475151f8d505d6b39c6fc"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc