mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	better handling of newlines which should hopefully eliminate new line duplication
This commit is contained in:
		
							parent
							
								
									1b3a113639
								
							
						
					
					
						commit
						bf22cc55e1
					
				| @ -1,7 +1,11 @@ | ||||
| function html2notecase(contents, note) { | ||||
|     //console.log("'" + contents + "'");
 | ||||
| 
 | ||||
|     // remove any possible extra newlines which might be inserted - all relevant new lines should be only in <br> and <p>
 | ||||
|     contents = contents.replace(/(?:\r\n|\r|\n)/, ''); | ||||
| 
 | ||||
|     contents = contents.replace(/<br><\/p>/g, '\n'); | ||||
|     contents = contents.replace(/<p><br><\/p>/g, '\n'); | ||||
|     contents = contents.replace(/<br \/>/g, '\n'); | ||||
|     contents = contents.replace(/<br>/g, '\n'); | ||||
|     contents = contents.replace(/<\/p>/g, '\n'); | ||||
| @ -144,7 +148,9 @@ function html2notecase(contents, note) { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     //console.log(contents);
 | ||||
|     contents = contents.trim(); | ||||
| 
 | ||||
|     //console.log('"' + contents + '"');
 | ||||
| 
 | ||||
|     note.detail.note_text = contents; | ||||
| } | ||||
| @ -43,7 +43,11 @@ function notecase2html(note) { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     noteText = noteText.replace(/(?:\r\n|\r|\n)/g, '<br />'); | ||||
|     noteText = noteText.replace(/(?:\r\n|\r)/g, '\n'); | ||||
| 
 | ||||
|     noteText = noteText.replace(/(.+)\n/g, '<p>$1</p>'); | ||||
| 
 | ||||
|     noteText = noteText.replace(/\n/g, '<p><br></p>'); | ||||
| 
 | ||||
|     noteText = noteText.replace(/  /g, '  '); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner