| 
									
										
										
										
											2021-01-10 22:51:10 -08:00
										 |  |  | {{ $source := (readFile (printf "code/%s" (.Get 1))) }} | 
					
						
							|  |  |  | {{ $allLines := split $source "\n" }} | 
					
						
							| 
									
										
										
										
											2019-08-26 18:48:12 -07:00
										 |  |  | {{ if not (eq (int (.Get 2)) 1) }} | 
					
						
							| 
									
										
										
										
											2021-01-10 22:51:10 -08:00
										 |  |  | {{ .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) }} | 
					
						
							| 
									
										
										
										
											2019-08-26 18:48:12 -07:00
										 |  |  | {{ else }} | 
					
						
							| 
									
										
										
										
											2021-01-10 22:51:10 -08:00
										 |  |  | {{ .Scratch.Set "remLines" $allLines }} | 
					
						
							| 
									
										
										
										
											2019-08-26 18:48:12 -07:00
										 |  |  | {{ end }} | 
					
						
							| 
									
										
										
										
											2021-01-10 22:51:10 -08:00
										 |  |  | {{ $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") }} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-12 01:37:55 -07:00
										 |  |  | {{ if (.Get 4) }} | 
					
						
							|  |  |  | {{ .Scratch.Set "opts" (printf ",%s" (.Get 4)) }} | 
					
						
							|  |  |  | {{ else }} | 
					
						
							|  |  |  | {{ .Scratch.Set "opts" "" }} | 
					
						
							|  |  |  | {{ end }} | 
					
						
							| 
									
										
										
										
											2021-01-10 22:51:10 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | {{ .Scratch.Set "bestLength" -1 }} | 
					
						
							|  |  |  | {{ .Scratch.Set "bestUrl" (printf "https://dev.danilafe.com/Web-Projects/blog-static/src/branch/master/code/%s" (.Get 1)) }} | 
					
						
							|  |  |  | {{ $filePath := (.Get 1) }} | 
					
						
							|  |  |  | {{ $scratch := .Scratch }} | 
					
						
							|  |  |  | {{ range $module, $props := .Site.Params.submoduleLinks }} | 
					
						
							|  |  |  | {{ $path := index $props "path" }} | 
					
						
							|  |  |  | {{ $bestLength := $scratch.Get "bestLength" }} | 
					
						
							|  |  |  | {{ if and (le $bestLength (len $path)) (hasPrefix $filePath $path) }} | 
					
						
							|  |  |  | {{ $scratch.Set "bestLength" (len $path) }} | 
					
						
							|  |  |  | {{ $scratch.Set "bestUrl" (printf "%s%s" (index $props "url") (strings.TrimPrefix $path $filePath)) }} | 
					
						
							|  |  |  | {{ end }} | 
					
						
							|  |  |  | {{ end }} | 
					
						
							| 
									
										
										
										
											2020-09-27 14:41:56 -07:00
										 |  |  | <div class="highlight-group"> | 
					
						
							| 
									
										
										
										
											2021-01-10 22:51:10 -08:00
										 |  |  |     <div class="highlight-label">From <a href="{{ .Scratch.Get "bestUrl" }}">{{ path.Base (.Get 1) }}</a>, | 
					
						
							| 
									
										
										
										
											2020-09-27 14:41:56 -07:00
										 |  |  |         {{ if eq (.Get 2) (.Get 3) }}line {{ .Get 2 }}{{ else }} lines {{ .Get 2 }} through {{ .Get 3 }}{{ end }}</div> | 
					
						
							| 
									
										
										
										
											2021-01-10 22:51:10 -08:00
										 |  |  |     {{ highlight (delimit $lines "\n") (.Get 0) (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts")) }} | 
					
						
							| 
									
										
										
										
											2020-09-27 14:41:56 -07:00
										 |  |  | </div> |