Make style generation module more loosely coupled by only caring about tags and class definitions

master
Sven Slootweg 7 years ago
parent 863a93e381
commit 17909f2ed1

@ -1,15 +1,15 @@
'use strict';
module.exports = function generateItemStyle(item, options) {
let style = Object.assign({}, options.defaultStyle);
module.exports = function generateItemStyle(tags, classes) {
let style = {};
item.tags.forEach((tag) => {
tags.forEach((tag) => {
if (tag.type === "class") {
tag.classNames.forEach((className) => {
if (options.classes[className] == null) {
if (classes[className] == null) {
throw new Error(`Encountered unrecognized class ${className} in text`);
} else {
Object.assign(style, options.classes[className]);
Object.assign(style, classes[className]);
}
});
}

Loading…
Cancel
Save