[FA-misc] Switches to using DTOs, updates frontend with details and reader page, updates novel import to be an upsert
This commit is contained in:
74
fictionarchive-web-astro/src/lib/utils/sanitizeChapter.ts
Normal file
74
fictionarchive-web-astro/src/lib/utils/sanitizeChapter.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import DOMPurify from 'isomorphic-dompurify';
|
||||
|
||||
/**
|
||||
* Sanitizes chapter HTML content with extended allowed tags.
|
||||
* More permissive than the description sanitizer to support
|
||||
* formatted novel content including headings, lists, and images.
|
||||
*/
|
||||
export function sanitizeChapterHtml(html: string): string {
|
||||
return DOMPurify.sanitize(html, {
|
||||
ALLOWED_TAGS: [
|
||||
// Basic formatting
|
||||
'b',
|
||||
'i',
|
||||
'em',
|
||||
'strong',
|
||||
'u',
|
||||
's',
|
||||
'strike',
|
||||
'del',
|
||||
'ins',
|
||||
// Structure
|
||||
'p',
|
||||
'br',
|
||||
'hr',
|
||||
'div',
|
||||
'span',
|
||||
// Headings
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
// Lists
|
||||
'ul',
|
||||
'ol',
|
||||
'li',
|
||||
// Quotes
|
||||
'blockquote',
|
||||
'q',
|
||||
'cite',
|
||||
// Preformatted
|
||||
'pre',
|
||||
'code',
|
||||
// Ruby (for Asian language annotations)
|
||||
'ruby',
|
||||
'rt',
|
||||
'rp',
|
||||
// Images
|
||||
'img',
|
||||
// Tables
|
||||
'table',
|
||||
'thead',
|
||||
'tbody',
|
||||
'tr',
|
||||
'th',
|
||||
'td'
|
||||
],
|
||||
ALLOWED_ATTR: [
|
||||
// Image attributes
|
||||
'src',
|
||||
'alt',
|
||||
'title',
|
||||
'width',
|
||||
'height',
|
||||
// Table attributes
|
||||
'colspan',
|
||||
'rowspan',
|
||||
// Generic styling (limited)
|
||||
'class'
|
||||
],
|
||||
ALLOW_DATA_ATTR: false
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user