mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	client: Apply syntax highlight to note preview
This commit is contained in:
		
							parent
							
								
									3af29a78dc
								
							
						
					
					
						commit
						dfa4f3cd84
					
				| @ -5,6 +5,7 @@ import attributeRenderer from "./attribute_renderer.js"; | |||||||
| import libraryLoader from "./library_loader.js"; | import libraryLoader from "./library_loader.js"; | ||||||
| import treeService from "./tree.js"; | import treeService from "./tree.js"; | ||||||
| import utils from "./utils.js"; | import utils from "./utils.js"; | ||||||
|  | import { applySyntaxHighlight } from "./syntax_highlight.js"; | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="note-list"> | <div class="note-list"> | ||||||
| @ -368,6 +369,8 @@ class NoteListRenderer { | |||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             applySyntaxHighlight($renderedContent); | ||||||
|  | 
 | ||||||
|             $content.append($renderedContent); |             $content.append($renderedContent); | ||||||
|             $content.addClass(`type-${type}`); |             $content.addClass(`type-${type}`); | ||||||
|         } catch (e) { |         } catch (e) { | ||||||
|  | |||||||
| @ -1,5 +1,10 @@ | |||||||
| import mime_types from "./mime_types.js"; | import mime_types from "./mime_types.js"; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Identifies all the code blocks under the specified hierarchy and uses the highlight.js library to obtain the highlighted text which is then applied on to the code blocks. | ||||||
|  |  *  | ||||||
|  |  * @param $container the container under which to look for code blocks and to apply syntax highlighting to them. | ||||||
|  |  */ | ||||||
| export function applySyntaxHighlight($container) { | export function applySyntaxHighlight($container) { | ||||||
|     const codeBlocks = $container.find("pre code"); |     const codeBlocks = $container.find("pre code"); | ||||||
|     for (const codeBlock of codeBlocks) { |     for (const codeBlock of codeBlocks) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran