ad_pubfiles/html-manipulations/addSummary.js

11 lines
307 B
JavaScript

//looks for an html comment pattern, and, if found,
//adds the text before it to the doc under the key `summary`.
const reg = /^(?<summary>.+)?<!--summary-above-->/s
export default (doc) => {
const result = reg.exec(doc._body);
if (result) {
doc.summary = result.groups.summary;
}
return doc;
}