Support rich text book descriptions

This commit is contained in:
mikiher 2025-01-22 08:53:23 +02:00
parent 66b90e0841
commit 286185329d
14 changed files with 136 additions and 83 deletions

View file

@ -1,11 +1,9 @@
const sanitizeHtml = require('../libs/sanitizeHtml')
const { entities } = require("./htmlEntities");
const { entities } = require('./htmlEntities')
function sanitize(html) {
const sanitizerOptions = {
allowedTags: [
'p', 'ol', 'ul', 'li', 'a', 'strong', 'em', 'del', 'br'
],
allowedTags: ['p', 'ol', 'ul', 'li', 'a', 'strong', 'em', 'del', 'br', 'b', 'i'],
disallowedTagsMode: 'discard',
allowedAttributes: {
a: ['href', 'name', 'target']
@ -34,6 +32,6 @@ function decodeHTMLEntities(strToDecode) {
if (entity in entities) {
return entities[entity]
}
return entity;
return entity
})
}