[markdown] provide hints to prevent line breaks in pill components

This commit is contained in:
bignutty 2025-02-22 16:10:09 +01:00
parent 7c4e952b2f
commit 2bb389ad93

View file

@ -40,7 +40,7 @@ module.exports.iconAsEmojiObject = function(icon){
}
/**
* Creates a favicon image via google s2
* Creates a favicon image via Google s2
* @param {string} url Url
* @param {Number} size Favicon Size
* @returns {string} Favicon URL
@ -122,30 +122,30 @@ module.exports.stringwrapPreserveWords = function(content = "", length, newlines
}
module.exports.pill = function(content = ""){
return " **` " + _escapeCodeblock(content) + "  `**"
return " **` " + _escapeCodeblock(content).replace(/ /g, " ") + "  `**"
}
module.exports.smallPill = function(content = ""){
return " ` " + _escapeCodeblock(content) + " `"
return " ` " + _escapeCodeblock(content).replace(/ /g, " ") + " `"
}
module.exports.iconPill = function(icon, content = ""){
return _icon(icon) + "  **` " + _escapeCodeblock(content) + "  `**"
return _icon(icon) + "  **` " + _escapeCodeblock(content).replace(/ /g, " ") + "  `**"
}
module.exports.smallIconPill = function(icon, content = ""){
return _icon(icon) + "  ` " + _escapeCodeblock(content) + "  `"
return _icon(icon) + "  ` " + _escapeCodeblock(content).replace(/ /g, " ") + "  `"
}
module.exports.iconLinkPill = function(icon, url, content = "", tooltip = ""){
if(tooltip.length) tooltip = ` '${tooltip}'`
if(content) return `${_icon(icon)} [**\` ${_escapeCodeblock(content)}  \`**](${url.replace(/\)/g, '\\)')}${tooltip})`
if(content) return `${_icon(icon)} [**\` ${_escapeCodeblock(content).replace(/ /g, " ")}  \`**](${url.replace(/\)/g, '\\)')}${tooltip})`
return url
}
module.exports.linkPill = function(url, content = "", tooltip = ""){
if(tooltip.length) tooltip = ` '${tooltip}'`
if(content) return `[**\` ${_escapeCodeblock(content)} \`**](${url.replace(/\)/g, '\\)')}${tooltip})`
if(content) return `[**\` ${_escapeCodeblock(content).replace(/ /g, " ")} \`**](${url.replace(/\)/g, '\\)')}${tooltip})`
return url
}