Browse Source
			
			
			templates: Fix front matter closing fence search
			
				This makes it choose first matching closing fence instead of last one,
which could appear in document body.
			
			
				master
			
			
		 
		
			
				
					
						 Matthew Holt
					
					5 years ago
						Matthew Holt
					
					5 years ago
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 2A349DD577D586A5
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
12 additions and 
0 deletions
			 
			
		 
		
			
				- 
					
					
					 
					modules/caddyhttp/templates/frontmatter.go
				
- 
					
					
					 
					modules/caddyhttp/templates/tplcontext_test.go
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -56,6 +56,7 @@ func extractFrontMatter(input string) (map[string]interface{}, string, error) { | 
			
		
	
		
			
				
					|  |  |  | 		if index >= 0 { | 
			
		
	
		
			
				
					|  |  |  | 			fmEndFenceStart = index | 
			
		
	
		
			
				
					|  |  |  | 			fmEndFence = fence | 
			
		
	
		
			
				
					|  |  |  | 			break | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	if fmEndFenceStart < 0 { | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -316,6 +316,17 @@ title: Welcome | 
			
		
	
		
			
				
					|  |  |  | 			expect: `Welcome`, | 
			
		
	
		
			
				
					|  |  |  | 			body:   "\n### Test", | 
			
		
	
		
			
				
					|  |  |  | 		}, | 
			
		
	
		
			
				
					|  |  |  | 		{ | 
			
		
	
		
			
				
					|  |  |  | 			// yaml with non-fence '...' line after closing fence (i.e. first matching closing fence should be used)
 | 
			
		
	
		
			
				
					|  |  |  | 			input: `--- | 
			
		
	
		
			
				
					|  |  |  | title: Welcome | 
			
		
	
		
			
				
					|  |  |  | --- | 
			
		
	
		
			
				
					|  |  |  | ### Test | 
			
		
	
		
			
				
					|  |  |  | ... | 
			
		
	
		
			
				
					|  |  |  | yeah`, | 
			
		
	
		
			
				
					|  |  |  | 			expect: `Welcome`, | 
			
		
	
		
			
				
					|  |  |  | 			body:   "\n### Test\n...\nyeah", | 
			
		
	
		
			
				
					|  |  |  | 		}, | 
			
		
	
		
			
				
					|  |  |  | 		{ | 
			
		
	
		
			
				
					|  |  |  | 			// toml
 | 
			
		
	
		
			
				
					|  |  |  | 			input: `+++ | 
			
		
	
	
		
			
				
					|  |  | 
 |