mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	fix(import/single): h1 not being removed due to downgrade to h2
This commit is contained in:
		
							parent
							
								
									6056b55bde
								
							
						
					
					
						commit
						cef464f88b
					
				@ -156,11 +156,12 @@ function importHtml(taskContext: TaskContext, file: File, parentNote: BNote) {
 | 
				
			|||||||
    const htmlTitle = importUtils.extractHtmlTitle(content);
 | 
					    const htmlTitle = importUtils.extractHtmlTitle(content);
 | 
				
			||||||
    const title = htmlTitle || utils.getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces);
 | 
					    const title = htmlTitle || utils.getNoteTitle(file.originalname, !!taskContext.data?.replaceUnderscoresWithSpaces);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    content = importUtils.handleH1(content, title);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (taskContext?.data?.safeImport) {
 | 
					    if (taskContext?.data?.safeImport) {
 | 
				
			||||||
        content = htmlSanitizer.sanitize(content);
 | 
					        content = htmlSanitizer.sanitize(content);
 | 
				
			||||||
    }    
 | 
					    }    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    content = importUtils.handleH1(content, title);
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    const {note} = noteService.createNewNote({
 | 
					    const {note} = noteService.createNewNote({
 | 
				
			||||||
        parentNoteId: parentNote.noteId,
 | 
					        parentNoteId: parentNote.noteId,
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
"use strict";
 | 
					"use strict";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function handleH1(content: string, title: string) {
 | 
					function handleH1(content: string, title: string) {
 | 
				
			||||||
    content = content.replace(/<h1>([^<]*)<\/h1>/gi, (match, text) => {
 | 
					    content = content.replace(/<h1[^>]*>([^<]*)<\/h1>/gi, (match, text) => {
 | 
				
			||||||
        if (title.trim() === text.trim()) {
 | 
					        if (title.trim() === text.trim()) {
 | 
				
			||||||
            return ""; // remove whole H1 tag
 | 
					            return ""; // remove whole H1 tag
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user