Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions layouts/partials/process-markdown-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -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/" -}}

Expand Down
14 changes: 14 additions & 0 deletions layouts/shortcodes/image.html
Original file line number Diff line number Diff line change
@@ -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%" }}
<a href='{{ relURL $fname }}' sdata-lightbox="{{- .Scratch.Get "file" -}}">
<img src='{{ relURL $fname }}'
{{ with .Get "width" }} width="{{.}}"{{ end }}
{{ with .Get "align"}} align="{{.}}"{{ end }}
{{ with .Get "alt"}} alt="{{.}}"{{ end }}
{{ with .Get "class"}} class="{{.}}"{{ end }}/>
</a>
Loading