Ghost/core/server/services/mega/segment-parser.js
Naz e04af28efe Added segment parser logic
refs https://github.com/TryGhost/Team/issues/828

- This is experimental segment extraction logic, more to follow. Alllows to extract arrays of email segments used in the email's HTML content
2021-06-30 17:43:28 +04:00

14 lines
312 B
JavaScript

const cheerio = require('cheerio');
const getSegmentsFromHtml = (html) => {
const $ = cheerio.load(html);
const allSegments = $('[data-gh-segment]')
.get()
.map(el => el.attribs['data-gh-segment']);
return allSegments;
};
module.exports.getSegmentsFromHtml = getSegmentsFromHtml;