{{- $duration := "7000" -}}
{{- $content := $ -}}
{{- $imageListPattern := `<ul>\s*(?:<li><figure>\s*<img[^>]*/?>\s*</figure>\s*</li>\s*)+</ul>` -}}
{{- $imageLists := findRE $imageListPattern $content -}}
{{- range $index,$il := $imageLists -}}
  {{- $listItems := findRE `<li><figure>\s*<img[^>]*/?>\s*</figure>\s*</li>` $il -}}
  {{- $items := `<ul>` -}}
  {{- range $i,$li := $listItems -}}
    {{- $img := index (findRE `<img[^>]*/?>` $li) 0 -}}
    {{- $items = print $items `<li id="c` $index `_slide` $i `">` $img `</li>` -}}
  {{- end -}}
  {{- $items = print $items `</ul>` -}}
  {{- $indicators := `<ol>` -}}
  {{- range $i,$li := $listItems -}}
    {{- $indicators = print $indicators `<li><a href="#c` $index `_slide` $i `"></a></li>` -}}
  {{- end -}}
  {{- $indicators = print $indicators `</ol>` -}}
  {{- $replacement := print `<div id="carousel_` $index `" class="auto-carousel" duration="` $duration `">` $items $indicators `<div class="prev">&lsaquo;</div><div class="next">&rsaquo;</div></div>` -}}
  {{- $content = replace $content $il $replacement -}}
{{- end -}}
{{- $content | safeHTML -}}
