From 8e8512290b4636f017f5bfebc0bd0aa408c0f4a4 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 19 Apr 2022 20:07:30 -0700 Subject: [PATCH] Fix invalid HTML --- content/posts/website-best-practices.md | 18 ++++++++++-------- layouts/shortcodes/codecaption.html | 2 +- layouts/shortcodes/codefigure.html | 9 +-------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/content/posts/website-best-practices.md b/content/posts/website-best-practices.md index a38996d..754ca4a 100644 --- a/content/posts/website-best-practices.md +++ b/content/posts/website-best-practices.md @@ -671,7 +671,9 @@ Most of my images will probably be screenshots that start as PNGs. My typical fl 6. Create a lossy AVIF image from the cropped full-color PNG, and include it in the `` element if it's smaller than the WebP. If color isn't important, use the YUV400 color space. 7. If the image is too light, repeat for a dark version of the image to display according to a `prefers-color-scheme: dark` media query. -{{}} {{< codecaption lang="shell" >}} +{{}} + +{{< codecaption lang="shell" id="png-pipeline" >}} this is a sample command to compress a PNG image using ImageMagick, `pngquant`, and `oxipng`. It shrinks the image, turns it grayscale, reduces the color palette, and then applies lossless Zopfli compression. @@ -684,7 +686,7 @@ convert ORIGINAL_FILE \ | oxipng -o max -Z --fix - --out OUTPUT_FILE ``` - +{{}} In general, avoid loading images just for decoration. Only use an image if it has a clear purpose that significantly adds to the content in a way that text can't replace, and provide alt-text as a fallback. Any level of detail that isn't necessary for getting the point across should be removed by lossy compression and cropping. @@ -1325,17 +1327,17 @@ A special thanks goes out to GothAlice for the questions she answered in `#webde [^13]: Consider disabling the JIT for your normal browsing too; doing so removes whole classes of vulnera­bilities. In Firefox, navigate to `about:config` and toggle some flags under javascript.options. - {{}} - - {{< codecaption >}}Firefox prefs to turn off JIT compilation {{< /codecaption >}} +
+
+ Code snippet 11: + Firefox prefs to turn off JIT compilation +
javascript.options.ion
     javascript.options.baselinejit
     javascript.options.native_regexp
     javascript.options.asmjs
-    javascript.options.wasm
- - {{}} + javascript.options.wasm
In Chromium and derivatives, run the browser with `--js-flags='--jitless'`; in the Tor Browser, set the security level to "Safer". diff --git a/layouts/shortcodes/codecaption.html b/layouts/shortcodes/codecaption.html index 7682ee9..390fb0e 100644 --- a/layouts/shortcodes/codecaption.html +++ b/layouts/shortcodes/codecaption.html @@ -1,6 +1,6 @@ {{ $codeIndex := (.Page.Scratch.Get "codeIndex") }}
- Code snippet {{ $codeIndex }}{{with .Get "lang"}} ({{ . }}){{end}}: + Code snippet {{ $codeIndex }}{{with .Get "lang"}} ({{ . }}){{end}}: {{ .Inner | markdownify | safeHTML }}
{{- .Page.Scratch.Set "codeIndex" (add 1 $codeIndex) -}} diff --git a/layouts/shortcodes/codefigure.html b/layouts/shortcodes/codefigure.html index e5d307a..d12efee 100644 --- a/layouts/shortcodes/codefigure.html +++ b/layouts/shortcodes/codefigure.html @@ -1,10 +1,3 @@ -{{ $codeIndex := .Page.Scratch.Get "codeIndex" }} -{{ $id := .Get "id" }} -
+
{{ .Inner | markdownify }}