Compare commits
8 Commits
b9a91e76ce
...
e531ebd992
| Author | SHA1 | Date | |
|---|---|---|---|
| e531ebd992 | |||
| 8a5bbf460b | |||
| 48bdf9ef08 | |||
| b1334455ea | |||
| a6425c7510 | |||
| 52ea5abbc8 | |||
| 67da389005 | |||
| a6a14c3909 |
@@ -1,11 +1,12 @@
|
|||||||
{{ $scratch := .scratch }}
|
{{- $scratch := .scratch -}}
|
||||||
{{ $scratch.Set "bestLength" -1 }}
|
{{- $scratch.Set "bestLength" -1 -}}
|
||||||
{{ $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) }}
|
{{- $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) -}}
|
||||||
{{ $filePath := .path }}
|
{{- $filePath := .path -}}
|
||||||
{{ range $path, $url := .submoduleLinks }}
|
{{- range $path, $url := .submoduleLinks -}}
|
||||||
{{ $bestLength := $scratch.Get "bestLength" }}
|
{{- $bestLength := $scratch.Get "bestLength" -}}
|
||||||
{{ if and (le $bestLength (len $path)) (hasPrefix $filePath $path) }}
|
{{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
|
||||||
{{ $scratch.Set "bestLength" (len $path) }}
|
{{- $scratch.Set "bestLength" (len $path) -}}
|
||||||
{{ $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) }}
|
{{- $scratch.Set "bestPath" $path -}}
|
||||||
{{ end }}
|
{{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<div class="highlight-group">
|
<div class="highlight-group" {{ with .attrs }}{{ . | safeHTMLAttr }}{{ end }}>
|
||||||
<div class="highlight-label">{{ i18n "from" }} <a href="{{ .url }}">{{ path.Base .path }}</a>{{ .comment }}</div>{{ .content }}
|
<div class="highlight-label">{{ i18n "from" }} <a href="{{ .url }}">{{ path.Base .path }}</a>{{ .comment }}</div>{{ .content }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1 +1,7 @@
|
|||||||
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts)) }}
|
{{- if (or .firstLine .lastLine) -}}
|
||||||
|
{{- page.Scratch.Set "highlightGroupAttrs" (printf "data-first-line=\"%v\" data-last-line=\"%v\" data-base-path=\"%s\" data-file-path=\"%v\"" .firstLine .lastLine .basePath .path) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if eq .language "Agda" -}}
|
||||||
|
{{- page.Scratch.Add "highlightGroupAttrs" " data-agda-block" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" (page.Scratch.Get "highlightGroupAttrs")) }}
|
||||||
|
|||||||
@@ -1,2 +1,11 @@
|
|||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
||||||
{{ partial "highlightgroup.html" (dict "url" (.Scratch.Get "bestUrl") "path" (.Get 1) "comment" ", entire file" "code" (readFile (printf "code/%s" (.Get 1))) "language" (.Get 0) "opts" "linenos=table") }}
|
{{- $groupconfig := dict
|
||||||
|
"url" (.Scratch.Get "bestUrl")
|
||||||
|
"basePath" (.Scratch.Get "bestPath")
|
||||||
|
"path" (.Get 1)
|
||||||
|
"comment" ", entire file"
|
||||||
|
"code" (readFile (printf "code/%s" (.Get 1)))
|
||||||
|
"language" (.Get 0)
|
||||||
|
"opts" "linenos=table"
|
||||||
|
-}}
|
||||||
|
{{ partial "highlightgroup.html" $groupconfig }}
|
||||||
|
|||||||
@@ -1,29 +1,40 @@
|
|||||||
{{ $source := (readFile (printf "code/%s" (.Get 1))) }}
|
{{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
|
||||||
{{ $allLines := split $source "\n" }}
|
{{- $allLines := split $source "\n" -}}
|
||||||
{{ if not (eq (int (.Get 2)) 1) }}
|
{{- if not (eq (int (.Get 2)) 1) -}}
|
||||||
{{ .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) }}
|
{{- .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}}
|
||||||
{{ else }}
|
{{- else -}}
|
||||||
{{ .Scratch.Set "remLines" $allLines }}
|
{{- .Scratch.Set "remLines" $allLines -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") }}
|
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") -}}
|
||||||
|
|
||||||
{{ if (.Get 4) }}
|
{{- if (.Get 4) -}}
|
||||||
{{ .Scratch.Set "opts" (printf ",%s" (.Get 4)) }}
|
{{- .Scratch.Set "opts" (printf ",%s" (.Get 4)) -}}
|
||||||
{{ else }}
|
{{- else -}}
|
||||||
{{ .Scratch.Set "opts" "" }}
|
{{- .Scratch.Set "opts" "" -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
|
|
||||||
{{ if (.Get 5) }}
|
{{- if (.Get 5) -}}
|
||||||
{{ .Scratch.Set "hidden" (.Get 5) }}
|
{{- .Scratch.Set "hidden" (.Get 5) -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
|
|
||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{- partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) -}}
|
||||||
{{ partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) }}
|
{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}}
|
||||||
|
|
||||||
{{ with (.Scratch.Get "hidden") }}
|
{{- with (.Scratch.Get "hidden") -}}
|
||||||
<details><summary>{{ . | markdownify }}</summary>
|
<details><summary>{{ . | markdownify }}</summary>
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ partial "highlightgroup.html" (dict "url" (.Scratch.Get "bestUrl") "path" (.Get 1) "comment" (.Scratch.Get "comment") "code" (delimit $lines "\n") "language" (.Get 0) "opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts"))) }}
|
{{- $groupconfig := dict
|
||||||
{{ with (.Scratch.Get "hidden") }}
|
"url" (.Scratch.Get "bestUrl")
|
||||||
|
"basePath" (.Scratch.Get "bestPath")
|
||||||
|
"path" (.Get 1)
|
||||||
|
"comment" (.Scratch.Get "comment")
|
||||||
|
"code" (delimit $lines "\n")
|
||||||
|
"firstLine" (int (.Get 2))
|
||||||
|
"lastLine" (int (.Get 3))
|
||||||
|
"language" (.Get 0)
|
||||||
|
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts"))
|
||||||
|
-}}
|
||||||
|
{{- partial "highlightgroup.html" $groupconfig -}}
|
||||||
|
{{- with (.Scratch.Get "hidden") -}}
|
||||||
</details>
|
</details>
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
|
|||||||
@@ -1,2 +1,9 @@
|
|||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
||||||
{{ partial "group.html" (dict "url" (.Scratch.Get "bestUrl") "path" (.Get 0) "comment" ", entire file" "content" (safeHTML (printf "<pre><code>%s</code></pre>" (htmlEscape (readFile (printf "code/%s" (.Get 0))))))) }}
|
{{- $groupconfig := dict
|
||||||
|
"url" (.Scratch.Get "bestUrl")
|
||||||
|
"basePath" (.Scratch.Get "bestPath")
|
||||||
|
"path" (.Get 0)
|
||||||
|
"comment" ", entire file"
|
||||||
|
"content" (safeHTML (printf "<pre><code>%s</code></pre>" (htmlEscape (readFile (printf "code/%s" (.Get 0))))))
|
||||||
|
-}}
|
||||||
|
{{ partial "group.html" $groupconfig }}
|
||||||
|
|||||||
Reference in New Issue
Block a user