From cdff194de8881844df1f6689f9d57e33293ebbf9 Mon Sep 17 00:00:00 2001 From: Andy Stark Date: Wed, 14 Oct 2026 16:18:30 +0100 Subject: [PATCH] DOC-7186: reinstate the image shortcode temporarily for older open PRs #4207 (DOC-7128) retired the image shortcode after every image on main had been converted to Markdown. Older open PRs that still contain {{< image >}} calls then failed the build ("template for shortcode "image" not found") until each was converted, which is causing friction. This restores the shortcode exactly as it was, so those PRs build again, until it can be retired a second time. layouts/shortcodes/image.html and layouts/partials/process-markdown-content.html are restored byte-for-byte to their pre-#4207 versions (71d877f82^). The partial's two image-shortcode rules have to come back as well, or a shortcode in an old PR would reach the AI Markdown/JSON feed as raw shortcode text. Nothing else from #4207 is reverted: the five deleted embeds were unused, and the README keeps teaching Markdown images, which all new content should use. Tested with a temporary page using the shortcode forms old PRs contain (plain, widthed with a bare path and unquoted width, an inline #no-click icon, and a screenshot in a list step), built under the production baseURL. The build passes, all four render the pre-#4207 markup with the /docs/latest/ prefix, and the feed turns each into an absolute Markdown image. main has no shortcode calls, so its own rendering doesn't change. Directive: before re-retiring the shortcode, scan open PRs for {{< image (not just main), or this happens again Ticket: DOC-7186 Co-Authored-By: Claude Opus 5.5 --- layouts/partials/process-markdown-content.html | 11 ++++++++--- layouts/shortcodes/image.html | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 layouts/shortcodes/image.html diff --git a/layouts/partials/process-markdown-content.html b/layouts/partials/process-markdown-content.html index 75ba1b08ca..61dbc14ef2 100644 --- a/layouts/partials/process-markdown-content.html +++ b/layouts/partials/process-markdown-content.html @@ -72,9 +72,14 @@ {{- $content = $content | replaceRE `\]\(/content/([^)#]*?)/index\.md` "](https://redis.io/docs/latest/$1" -}} {{- $content = $content | replaceRE `\]\(/content/([^)#]*?)\.md` "](https://redis.io/docs/latest/$1" -}} -{{- /* Markdown images: drop the `{width="..." class="..."}` line render-image.html - reads, which would otherwise reach the output as literal text, then - absolutize the path. */ -}} +{{- /* Fix images - handle both HTML-escaped entities and literal characters */ -}} +{{- /* Pattern for HTML-escaped: {{< image filename="path" [alt="..."] >}} */ -}} +{{- $content = $content | replaceRE "\\{\\{<\\s*image\\s+filename="/?([^&]+)"[^}]*>\\}\\}" "![$1](https://redis.io/docs/latest/$1)" -}} +{{- /* Pattern for literal: {{< image filename="path" [alt="..."] >}} */ -}} +{{- $content = $content | replaceRE `\{\{<\s*image\s+filename="/?([^"]+)"[^}]*>\}\}` "![$1](https://redis.io/docs/latest/$1)" -}} +{{- /* Markdown images that replace the `image` shortcode (DOC-7128): drop the + `{width="..." class="..."}` line render-image.html reads, which would + otherwise reach the output as literal text, then absolutize the path. */ -}} {{- $content = $content | replaceRE `(?m)(!\[[^\]\n]*\]\([^)\n]*\))[ \t]*\n[ \t>]*\{(?:\s*\w+="[^"]*")+\s*\}[ \t]*$` "$1" -}} {{- $content = $content | replaceRE `(!\[[^\]\n]*\]\()/(?:static/)?images/` "${1}https://redis.io/docs/latest/images/" -}} diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html new file mode 100644 index 0000000000..1b13a857b4 --- /dev/null +++ b/layouts/shortcodes/image.html @@ -0,0 +1,14 @@ +{{ $fname := .Get "filename" | strings.TrimLeft "/" }} +{{ if not (hasPrefix $fname "/") }} + {{ .Scratch.Set "file" (printf "/%s" $fname) }} +{{ else }} + {{ .Scratch.Set "file" $fname }} +{{ end }} +{{- $width := .Get "width" | default "75%" }} + + {{.}} +