Add a Description field to the Guide information dialog
Reuses the guide's existing descriptionHtml/descriptionText, which already renders on the PDF cover and at the top of every other export format, so it surfaces alongside author/co-authors/organization with no exporter changes needed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
@@ -187,3 +187,21 @@ function fmtDate(iso) {
|
||||
|
||||
const escapeHtml = (s) => String(s ?? '')
|
||||
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
|
||||
/** Inverse of textToHtml, for loading sanitized description HTML into a plain textarea. */
|
||||
function htmlToPlainText(html) {
|
||||
return String(html || '')
|
||||
.replace(/<(br|\/p|\/div|\/li|\/h[1-6])\s*\/?>/gi, '\n')
|
||||
.replace(/<[^>]*>/g, '')
|
||||
.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, '\'').replace(/&/g, '&')
|
||||
.replace(/[ \t]+/g, ' ').replace(/\s*\n\s*/g, '\n').trim();
|
||||
}
|
||||
|
||||
/** Plain textarea text -> sanitizer-allowed paragraph HTML (blank line = new paragraph). */
|
||||
function textToHtml(text) {
|
||||
const trimmed = String(text || '').trim();
|
||||
if (!trimmed) return '';
|
||||
return trimmed.split(/\n{2,}/)
|
||||
.map((para) => `<p>${escapeHtml(para).replace(/\n/g, '<br>')}</p>`)
|
||||
.join('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user