How can I keep post views on lists

AI-generated summary

How can I keep post views on lists

ProjeDEV is looking for a way to display poetry excerpts on the homepage or category listings without losing the original line breaks. They have tried different themes and plugins, but nothing has worked.

pfaffman suggests checking the traditional markdown linebreaks SiteSetting, but ProjeDEV confirms that this doesn’t solve the issue.

Canapin suggests that a plugin might be needed to override the default behavior and provides some links to relevant resources.

Don offers a solution using CSS, suggesting to add white-space: pre-line to the topic-list class. This solution works, as confirmed by ProjeDEV.

Hi,
We have a poetry forum. In a single post, it looks normal like a poem, but the excerpt display view becomes a paragraph or combined text style on the homepage or category listings. The original post views are lost. I tried different things, different themes or the “topic list previews” plugin didn’t work. How can I show excerpts like poetry (e.g. first three lines or max lines with excerpt length) on homepage or specific category page.
Thanks for support.

You might check the value of SiteSetting traditional markdown linebreaks. The description reads: “Use traditional linebreaks in Markdown, which require two trailing spaces for a linebreak.”

That is a bit confusing, but I think that you have this checked and you want it unchecked. Or maybe I’m confused.

Thanks Jay, I tried but it didn’t work. I don’t know how but in the excerpt it combines all the sentences into one paragraph

Hi Proje DEV! :slight_smile:

Are you using Topic List Excerpts?

I believe you need a plugin if you want to override it to keep line breaks.

I think his is what would need to be overridden: discourse/app/controllers/topics_controller.rb at main · discourse/discourse · GitHub

More specifically, this line:

I didn’t try, but this may be useful for this purpose: Override existing Discourse methods in plugins

I’d be happy to have a look, but I don’t have a development install right now (and I’m bad at coding, so hopefully someone more skilled will have a more suitable answer). :slight_smile:

Hello, I think you can try it with white-space: pre-line it will keeps the topic line breaks in excerpt. :slightly_smiling_face:

Add this to Common > CSS

.topic-list {
  a.topic-excerpt {
    white-space: pre-line;
  }
}

Thanks Don. It works :+1: