mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 23:59:01 +02:00
1be43911b4
Set Prettier's "trailingComma" setting to "es5" GitOrigin-RevId: 9f14150511929a855b27467ad17be6ab262fe5d5
28 lines
605 B
JavaScript
28 lines
605 B
JavaScript
const sanitizeHtml = require('sanitize-html')
|
|
const sanitizeOptions = {
|
|
html: {
|
|
allowedTags: ['span', 'b', 'br', 'i'],
|
|
allowedAttributes: {
|
|
span: ['style', 'class'],
|
|
},
|
|
},
|
|
plainText: {
|
|
allowedTags: [],
|
|
allowedAttributes: {},
|
|
},
|
|
}
|
|
|
|
function cleanHTML(text, isPlainText) {
|
|
if (!isPlainText) return sanitizeHtml(text, sanitizeOptions.html)
|
|
return sanitizeHtml(text, sanitizeOptions.plainText)
|
|
}
|
|
|
|
function displayLink(text, url, isPlainText) {
|
|
return isPlainText ? `${text} (${url})` : `<a href="${url}">${text}</a>`
|
|
}
|
|
|
|
module.exports = {
|
|
cleanHTML,
|
|
displayLink,
|
|
}
|