2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- $allLines := split $source "\n" -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:36:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $scratch := newScratch -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $remLines := $allLines -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- if not (eq (int (.Get 2)) 1) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $remLines = after (sub (int (.Get 2)) 1) $allLines -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) $remLines -}}
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-15 01:37:18 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $opts := "" -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- if (.Get 4) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $opts = printf ",%s" (.Get 4) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-15 01:37:18 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- if (.Get 5) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:36:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $scratch.Set "hidden" (.Get 5) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-11 23:20:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $prefixLength := "" -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- $joinedLines := "" -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-25 19:02:44 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- if or (.Page.Params.left_align_code) (.Get 6) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $prefixLength = -1 -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-25 19:02:44 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- range $line := $lines -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- $leading := sub (len $line) (len (strings.TrimLeft " " $line)) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- if and (ne $line "") (or (eq $prefixLength -1) (le $leading $prefixLength)) -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- $prefixLength = $leading -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-25 19:02:44 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- range $line := $lines -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $joinedLines = add $joinedLines (substr $line $prefixLength) -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- $joinedLines = add $joinedLines "\n" -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-25 19:02:44 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- else -}}
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $joinedLines = delimit $lines "\n" -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-12-25 19:02:44 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:50:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1) "lines" (slice (.Get 2) (.Get 3))) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:36:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- partial "linerangestr.html" (dict "scratch" $scratch "from" (.Get 2) "to" (.Get 3)) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-15 01:37:18 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:36:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- with ($scratch.Get "hidden") -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								<details><summary>{{- . | markdownify -}}</summary>
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:31:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $groupconfig := dict
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:36:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								       "url" ($scratch.Get "bestUrl")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       "basePath" ($scratch.Get "bestPath")
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 20:39:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								       "path" (.Get 1)
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:36:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								       "comment" ($scratch.Get "comment")
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								       "code" $joinedLines
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 20:39:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								       "firstLine" (int (.Get 2))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       "lastLine" (int (.Get 3))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       "language" (.Get 0)
							 | 
						
					
						
							
								
									
										
										
										
											2025-03-30 22:45:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								       "offset" $prefixLength
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       "opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) $opts)
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:31:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- partial "highlightgroup.html" $groupconfig -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:36:54 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- with ($scratch.Get "hidden") -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-11 23:20:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								</details>
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 |