From 3cda34976fb776ab78cc4ac5725a569d59391900 Mon Sep 17 00:00:00 2001 From: loikein Date: Tue, 18 Apr 2023 00:29:12 +0100 Subject: [PATCH] refine figure --- assets/scss/components/code-highlight.scss | 4 +- assets/scss/vendor/tufte.scss | 5 +- layouts/shortcodes/figure.html | 70 ++++++++++++---------- layouts/shortcodes/marginnote.html | 6 +- layouts/shortcodes/sidenote.html | 8 +-- 5 files changed, 52 insertions(+), 41 deletions(-) diff --git a/assets/scss/components/code-highlight.scss b/assets/scss/components/code-highlight.scss index f223756..9225bc8 100644 --- a/assets/scss/components/code-highlight.scss +++ b/assets/scss/components/code-highlight.scss @@ -29,6 +29,8 @@ $ht-code-border-radius: .4em; &::before{ content: "> "; + // font-family: "Noto Emoji"; + font-family: inherit; position: absolute; left: 0; color: #111; @@ -65,7 +67,7 @@ $ht-code-border-radius: .4em; @media screen and (max-width: 760px) { - .highlight .chroma { + .highlight { width: 90%; } } diff --git a/assets/scss/vendor/tufte.scss b/assets/scss/vendor/tufte.scss index 8aebf71..8f281e4 100644 --- a/assets/scss/vendor/tufte.scss +++ b/assets/scss/vendor/tufte.scss @@ -310,13 +310,12 @@ div.table-wrapper { } @media screen and (max-width: 760px) { + h2, + h3, p, footer { width: 90%; } - pre.code { - width: 87.5%; - } ul { width: 85%; } diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 097f5a9..5b058ef 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -1,47 +1,57 @@ +{{ $alt := .Get "alt" | default "Image" }} {{ $type := .Get "type" | default "normal" }} - -{{ if not (eq $type "margin") }} - {{ if eq $type "full" }} -
- {{ else }} -
- {{ end }} -{{ end }} + +{{- $label := printf "%#v" (add .Ordinal 1) | printf "%s%s" "marginfig-" | printf "%s" -}} +{{- if .Get "label" -}} +{{- $label = .Get "label" -}} +{{- end -}} - -{{ if eq $type "full" }} + +{{- if not (eq $type "margin") -}} + {{ if eq $type "full" }} +
+ {{ else }} +
+ {{ end }} +{{- end -}} + + +{{- if eq $type "full" -}} {{ with .Get "link" }}{{ end }} - + {{ $alt }} {{ if .Get "link" }}{{ end }}
-{{ else }}{{/* margin or normal */}} - - - - {{ if eq $type "margin" }} +{{- else -}} + + {{- if or (or (.Get "caption") (.Get "attr")) (eq $type "margin") -}} + + + + {{- end -}} + + {{- if eq $type "margin" -}} {{ with .Get "link" }}{{ end }} - + {{ $alt }} {{ if .Get "link" }}{{ end }} - {{ end }} -{{ end }} + {{- end -}} -{{ with .Get "title"}}{{ . }} {{ end}} -{{ with .Get "caption"}}{{ . }}{{ end }} -{{ with .Get "attrlink"}}{{ end }} -{{ with .Get "attr" }}{{ . }}{{ end }} -{{ if .Get "attrlink" }}{{ end }} +{{- end -}} - -{{ if eq $type "full" }} +{{ with .Get "title"}}{{ . | markdownify }}. {{ end}} +{{ with .Get "caption"}}{{ . | markdownify }}{{ end }} +{{ with .Get "attr" }}{{ . | markdownify }}.{{ end }} + + +{{ if eq $type "full" }}
-{{ else }} - +{{ else }} + {{- if or (or (.Get "caption") (.Get "attr")) (eq $type "margin") -}}{{- end -}} {{ end }} -{{ if ( eq $type "normal" ) }} +{{ if (eq $type "normal") }} {{ with .Get "link" }}{{ end }} - + {{ $alt }} {{ if .Get "link" }}{{ end }} {{ end }} diff --git a/layouts/shortcodes/marginnote.html b/layouts/shortcodes/marginnote.html index fb0e15f..97baf92 100644 --- a/layouts/shortcodes/marginnote.html +++ b/layouts/shortcodes/marginnote.html @@ -1,7 +1,7 @@ -{{- $marginnoteDomIdSuffix := (add .Ordinal 1) -}} +{{- $label := (add .Ordinal 1) -}} {{- $ind := .Get "ind" | default .Site.Params.marginNoteInd -}} - - + + {{ .Inner | markdownify}} diff --git a/layouts/shortcodes/sidenote.html b/layouts/shortcodes/sidenote.html index d769229..c74d462 100644 --- a/layouts/shortcodes/sidenote.html +++ b/layouts/shortcodes/sidenote.html @@ -3,9 +3,9 @@ {{- else -}} {{- $.Page.Scratch.Set "sidenoteCounter" 1 -}} {{- end -}} -{{- $sidenoteDomIdSuffix := $.Page.Scratch.Get "sidenoteCounter" -}} - - +{{- $label := $.Page.Scratch.Get "sidenoteCounter" -}} + + -({{ $sidenoteDomIdSuffix }}){{ .Inner | markdownify }} +({{ $label }}){{ .Inner | markdownify }}