Git Product home page Git Product logo

Comments (5)

snej avatar snej commented on July 19, 2024

I figured out how to strip the HTML links from the description text by using the plainify filter. But that also turns non-ascii characters into HTML escapes, so I had to run it through htmlUnescape too. Here's a diff:

diff --git a/layouts/_default/li.html b/layouts/_default/li.html
index 6c65511..f4b5e4a 100644
--- a/layouts/_default/li.html
+++ b/layouts/_default/li.html
@@ -14,10 +14,10 @@
   {{- end }}
   <article class="card-body">
     <h2 class="card-title">{{ .Title }}</h2>
-    <p class="card-text">{{ if (isset .Params "description") }}{{ index .Params "description" }}{{ else }}{{ .Summary }}{{ end }}</p>
+    <p class="card-text">{{ if (isset .Params "description") }}{{ index .Params "description" | plainify | htmlUnescape }}{{ else }}{{ .Summary | plainify | htmlUnescape }}{{ end }}</p>
     <div class="card-subtext muted-text">
       <p>Posted <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "Jan 2, 2006" }}</time></p>
       {{ if (isset .Params "categories") }}<p>{{ range .Params.categories }}#{{ . | urlize | title }} {{ end }}</p>{{ end }}
     </div>
   </article>
-</a>
\ No newline at end of file
+</a>

from aether.

josephhutch avatar josephhutch commented on July 19, 2024

Thanks for opening the issue @snej! What version of Hugo are you running? I am unable to reproduce this issue on 0.63.2. Also, are you doing anything special to put a link in the description? I tried markdown, html a tag, and an html a tag with the raw shortcode. I'm happy to fix this, I just want to understand what is going on on my end.

from aether.

snej avatar snej commented on July 19, 2024

I've got Hugo v0.74.3. It could be the browser — I'm using Safari on Mac OS 10.15.

Nothing special for the description ... I've just got some posts with MarkDown links within the first few sentences of the body.

from aether.

josephhutch avatar josephhutch commented on July 19, 2024

Fixed in c0c3158.

I found out that Hugo only preserves html tags in the summary when using the <!--more--> summary divider (I'm assuming that's what you were using @snej). The description parameter is not parsed by Hugo so no need for the plainify function there. Let me know if you have any other issues.

from aether.

snej avatar snej commented on July 19, 2024

Aha! I was indeed using <!--more-->. Thanks for the fix.

from aether.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.