chore: remove old parser

This commit is contained in:
Oliver Eyton-Williams
2021-02-01 19:31:39 +01:00
committed by Mrugesh Mohapatra
parent e3511f2930
commit a3a678b7af
139 changed files with 4 additions and 4 deletions

View File

@ -0,0 +1,27 @@
const { isEmpty } = require('lodash');
const getAllBetween = require('./utils/between-headings');
const mdastToHTML = require('./utils/mdast-to-html');
function addText(sectionIds) {
if (!sectionIds || !Array.isArray(sectionIds) || sectionIds.length <= 0) {
throw new Error('addText must have an array of section ids supplied');
}
function transformer(tree, file) {
for (const sectionId of sectionIds) {
const textNodes = getAllBetween(tree, `--${sectionId}--`);
const sectionText = mdastToHTML(textNodes);
if (!isEmpty(sectionText)) {
file.data = {
...file.data,
[sectionId]: `<section id="${sectionId}">
${sectionText}
</section>`
};
}
}
}
return transformer;
}
module.exports = addText;