Compare commits

..

No commits in common. "806d3a318f4e83141e591db813a02a5433b865bc" and "4ff04221b08b1eb85e8cedeee6bf37975803bb21" have entirely different histories.

5 changed files with 34 additions and 39 deletions

View File

@ -1,9 +0,0 @@
{{ if and (eq .Type "alert") (eq .AlertType "todo") -}}
<div style="background-color: tomato; color: white; padding: 10px;">
<em>TODO: </em>{{- .Text | plainify -}}
</div>
{{- else -}}
<blockquote {{- with .Attributes.id }} id="{{ . }}"{{ end }}>
{{ .Text -}}
</blockquote>
{{- end }}

View File

@ -1,25 +1,24 @@
{{- $class := "" -}}
{{- $icon := "" -}}
{{- $scratch := newScratch -}}
{{- $absoluteDest := absLangURL .Destination -}}
{{- $siteRootUrl := absLangURL "" -}}
{{- $isExternal := not (hasPrefix $absoluteDest $siteRootUrl) -}}
{{- $isSamePage := hasPrefix .Destination "#" -}}
{{- if $isSamePage -}}
{{- $class = "same-page-link" -}}
{{- $scratch.Set "class" "same-page-link" -}}
{{- if index (.Page.Scratch.Get "definedSections") .Destination -}}
{{- $icon = "arrow-up" -}}
{{- $scratch.Set "icon" "arrow-up" -}}
{{- else -}}
{{- /* Do not render "down" links because don't know how to distinguish unseen titles from paragraph links. */ -}}
{{- /* $icon = "arrow-down" */ -}}
{{- /* $scratch.Set "icon" "arrow-down" */ -}}
{{- end -}}
{{- else if $isExternal -}}
{{- $class = "external-link" -}}
{{- $icon = "external-link" -}}
{{- $scratch.Set "class" "external-link" -}}
{{- $scratch.Set "icon" "external-link" -}}
{{- end -}}
<a href="{{ .Destination | safeURL }}"
{{- with .Title }} title="{{ . }}"{{ end -}}
{{- with $class -}}
{{- with $scratch.Get "class" -}}
class="{{ . }}"
{{- end -}}
{{- if (and site.Params.externalLinksInNewTab $isExternal) -}}
@ -27,6 +26,6 @@
{{- end -}}
>
{{- with .Text | safeHTML }}{{ . }}{{ end -}}
{{- with $icon -}}{{- partial "icon.html" . -}}{{- end -}}
{{- with $scratch.Get "icon" -}}{{- partial "icon.html" . -}}{{- end -}}
</a>
{{- /* chomp trailing newline */ -}}

View File

@ -1,11 +1,12 @@
{{- $highlightGroupAttrs := (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- $scratch := newScratch -}}
{{- $scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- if (or .firstLine .lastLine) -}}
{{- $highlightGroupAttrs = add $highlightGroupAttrs (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}}
{{- $scratch.Add "highlightGroupAttrs" (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}}
{{- end -}}
{{- if eq (lower .language) "agda" -}}
{{- $highlightGroupAttrs = add $highlightGroupAttrs " data-agda-block" -}}
{{- $scratch.Add "highlightGroupAttrs" " data-agda-block" -}}
{{- end -}}
{{- with .offset -}}
{{- $highlightGroupAttrs = add $highlightGroupAttrs (printf " data-source-offset=\"%v\"" .) -}}
{{- $scratch.Add "highlightGroupAttrs" (printf " data-source-offset=\"%v\"" .) -}}
{{- end -}}
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" $highlightGroupAttrs) }}
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" ($scratch.Get "highlightGroupAttrs")) }}

View File

@ -1,38 +1,39 @@
{{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
{{- $allLines := split $source "\n" -}}
{{- $scratch := newScratch -}}
{{- $remLines := $allLines -}}
{{- if not (eq (int (.Get 2)) 1) -}}
{{- $remLines = after (sub (int (.Get 2)) 1) $allLines -}}
{{- $scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}}
{{- else -}}
{{- $scratch.Set "remLines" $allLines -}}
{{- end -}}
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) $remLines -}}
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) ($scratch.Get "remLines") -}}
{{- $opts := "" -}}
{{- if (.Get 4) -}}
{{- $opts = printf ",%s" (.Get 4) -}}
{{- $scratch.Set "opts" (printf ",%s" (.Get 4)) -}}
{{- else -}}
{{- $scratch.Set "opts" "" -}}
{{- end -}}
{{- if (.Get 5) -}}
{{- $scratch.Set "hidden" (.Get 5) -}}
{{- end -}}
{{- $prefixLength := "" -}}
{{- $joinedLines := "" -}}
{{- if or (.Page.Params.left_align_code) (.Get 6) -}}
{{- $prefixLength = -1 -}}
{{- $scratch.Set "prefixLength" -1 -}}
{{- range $line := $lines -}}
{{- $leading := sub (len $line) (len (strings.TrimLeft " " $line)) -}}
{{- if and (ne $line "") (or (eq $prefixLength -1) (le $leading $prefixLength)) -}}
{{- $prefixLength = $leading -}}
{{- if and (ne $line "") (or (eq ($scratch.Get "prefixLength") -1) (le $leading ($scratch.Get "prefixLength"))) -}}
{{- $scratch.Set "prefixLength" $leading -}}
{{- end -}}
{{- end -}}
{{- $scratch.Set "joinedLines" "" -}}
{{- range $line := $lines -}}
{{- $joinedLines = add $joinedLines (substr $line $prefixLength) -}}
{{- $joinedLines = add $joinedLines "\n" -}}
{{- $scratch.Add "joinedLines" (substr $line ($scratch.Get "prefixLength")) -}}
{{- $scratch.Add "joinedLines" "\n" -}}
{{- end -}}
{{- else -}}
{{- $joinedLines = delimit $lines "\n" -}}
{{- $scratch.Set "joinedLines" (delimit $lines "\n") -}}
{{- end -}}
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1) "lines" (slice (.Get 2) (.Get 3))) -}}
@ -46,12 +47,12 @@
"basePath" ($scratch.Get "bestPath")
"path" (.Get 1)
"comment" ($scratch.Get "comment")
"code" $joinedLines
"code" ($scratch.Get "joinedLines")
"firstLine" (int (.Get 2))
"lastLine" (int (.Get 3))
"language" (.Get 0)
"offset" $prefixLength
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) $opts)
"offset" ($scratch.Get "prefixLength")
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) ($scratch.Get "opts"))
-}}
{{- partial "highlightgroup.html" $groupconfig -}}
{{- with ($scratch.Get "hidden") -}}

View File

@ -0,0 +1,3 @@
<div style="background-color: tomato; color: white; padding: 10px;">
<em>TODO: </em>{{- .Inner -}}
</div>