You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
407 B
JavaScript
20 lines
407 B
JavaScript
'use strict';
|
|
|
|
module.exports = function generateItemStyle(tags, classes) {
|
|
let style = {};
|
|
|
|
tags.forEach((tag) => {
|
|
if (tag.type === "class") {
|
|
tag.classNames.forEach((className) => {
|
|
if (classes[className] == null) {
|
|
throw new Error(`Encountered unrecognized class ${className} in text`);
|
|
} else {
|
|
Object.assign(style, classes[className]);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
return style;
|
|
}
|