HUGO

Remove a complete HTML block (from RSS or page)

Hi, how can we remove a complete HTML block (iframe, video) from a RSS feed rendering full content ?

RSS having these blocks don’t seem valid, and it could be used on any page.

Thanks a lot,

In the RSS template, pass the content through replaceRE before rendering. Provide a specific example, and the existing RSS template code, if you need further assistance.

Hi, thanks a lot for your reply.

How could you remove all the code from a block that is rendered like that in RSS feed ?

<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/QXlT9651svA" allowfullscreen loading="lazy" title="Palpation des seins (Dr Jean-Philippe Harlicot)"></iframe>

Thank you very much for your time !

I need to know everything around it as well… all the code.

my 2cents

try to use planify to get the plain text

Hi,

thanks for your help and sorry for the delay.

Sadly plainify ruins all the layout.

In markdown: {{< iframe url="https://splf.fr/videos-zephir/" title="SPLF: vidéos pour la maîtrise des inhalateurs">}}

Iframe shortcode:

<div class="border rounded">
  <iframe
    class="border-0 w-100"
    src="{{ .Get "url" }}"
    allowfullscreen
    height="600"
    loading="lazy"
    title="{{ if .Get "title" }}{{ .Get "title" }}{{ else }}Description manquante{{ end }}"
  ></iframe>
</div>

For now my RSS content is <description>{{ .Content | html }}</description> to preserve layout.

Thanks a lot and have a good weekend

layouts/_default/rss.xml

{{ $regex := `(?s)<div class="border rounded">\s*<iframe.+?iframe>\s*</div>` }}
<description>{{ .Content | safeHTML | replaceRE $regex "" }}</description>
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.