2

Long Description filed has \n in it to give a line break. It works perfectly on default browser mode but doesn't encode for Crawler and AMP page

Tried:

  <p itemprop="description" style="white-space: pre-wrap">@Html.Raw(Model.Restaurant.Description.Replace("\n\n", "<br />"))</p> 

displayed as

Crawler and AMP mode

KFC KFC, until 1991 known as Kentucky Fried Chicken, is an American fast food restaurant chain that specializes in fried chicken.\n\nKFC menu is available online. Order now your KFC food and view their online menu prices

Normal Mode:

KFC KFC, until 1991 known as Kentucky Fried Chicken, is an American fast food restaurant chain that specializes in fried chicken.

KFC menu is available online. Order now your KFC food and view their online menu prices

Bachcha Singh
  • 3,850
  • 3
  • 24
  • 38
monda
  • 3,809
  • 15
  • 60
  • 84

2 Answers2

0

Use the CSS white-space property

<span itemprop="description" style="white-space: pre-line">@Model.Restaurant.Description</span>

white-space: pre-line

Durgesh Pandey
  • 2,314
  • 4
  • 29
  • 43
0

Finally found the trick!

<p itemprop="description" style="white-space: pre-wrap">>@Html.Raw(Html.Encode(Model.Restaurant.Description).Replace(@"\n", "<br />"))</p>
monda
  • 3,809
  • 15
  • 60
  • 84