mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
1be43911b4
Set Prettier's "trailingComma" setting to "es5" GitOrigin-RevId: 9f14150511929a855b27467ad17be6ab262fe5d5
27 lines
605 B
JavaScript
27 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,
|
|
}
|