Skip to content

Commit dabfa41

Browse files
Fix inline SVGs with svg: namespace prefix (#30)
SVGs processed by BeautifulSoup's XML parser have namespaced tags (e.g. <svg:svg>, <svg:path>) which browsers don't render when inlined in HTML. Strip the svg: prefix before injecting into the page. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b2cca05 commit dabfa41

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎themes/alltuner-theme/layouts/partials/logo-carousel.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<img src="/statics/img/logos/{{ .logoDark }}" alt="{{ .name }} logo" class="max-h-8 max-w-24 w-auto h-auto grayscale hidden dark:block dark:opacity-30" width="120" height="40" loading="eager">
1212
{{ else if strings.HasSuffix .logo ".svg" }}
1313
{{ $svg := os.ReadFile (printf "static/statics/img/logos/%s" .logo) }}
14+
{{ $svg = replaceRE `<(/?)svg:` `<${1}` $svg }}
1415
{{ $svg = replaceRE `<svg\b` (printf `<svg role="img" aria-label="%s logo" class="max-h-8 max-w-24 w-auto h-auto grayscale opacity-40 dark:opacity-30"` .name) $svg 1 }}
1516
{{ $svg | safeHTML }}
1617
{{ else }}
@@ -30,6 +31,7 @@
3031
<img src="/statics/img/logos/{{ .logoDark }}" alt="{{ .name }} logo" class="max-h-8 max-w-24 w-auto h-auto grayscale hidden dark:block dark:opacity-30" width="120" height="40" loading="eager">
3132
{{ else if strings.HasSuffix .logo ".svg" }}
3233
{{ $svg := os.ReadFile (printf "static/statics/img/logos/%s" .logo) }}
34+
{{ $svg = replaceRE `<(/?)svg:` `<${1}` $svg }}
3335
{{ $svg = replaceRE `<svg\b` (printf `<svg aria-hidden="true" class="max-h-8 max-w-24 w-auto h-auto grayscale opacity-40 dark:opacity-30"`) $svg 1 }}
3436
{{ $svg | safeHTML }}
3537
{{ else }}

0 commit comments

Comments
 (0)