Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lukaz 44 posts 203 karma points
    Mar 24, 2020 @ 14:23
    Lukaz
    0

    Umbraco 8 - How to remove paragraph tags - rich text editor

    Hi all,

    How to remove paragraph tags I get in my design using rich text editor in Umbraco 8?

    Umbraco 7, Razor

    @Umbraco.Field("yourDocumentPropertyAliasName", removeParagraphTags:true)

    Links: StackOverflow simillar question Umbraco Forum post regarding Umbraco library

  • Yakov Lebski 594 posts 2350 karma points
    Mar 24, 2020 @ 18:17
    Yakov Lebski
    1

    You can use

    Html.StripHtml(Model.Value<string>("pageText"),"p")
    
  • Lukaz 44 posts 203 karma points
    Mar 25, 2020 @ 08:01
    Lukaz
    0

    Using your code I get completely stripped string even if string contains other elements like

    <strong></strong> or &amp;
    

    The hack I'm using right now is:

    @Html.Raw(Model.Value<string>("bodyText").Replace("<p>","").Replace("</p>", ""))
    

    I also found this post claiming the same as you are, but it doesn't work like it should. I'm using Umbraco 8.4.0

    Link: Html.StripHtml + umbraco 8

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Mar 25, 2020 @ 09:27
    Søren Gregersen
    0

    it doesn't work like it should

    remember to open an issue on github if something is not working :)

  • bikeman 21 posts 104 karma points
    Nov 24, 2020 @ 12:27
    bikeman
    2

    Why are hacks that remove the first or even all p tags repeatedly offered as a solution.

    A RTE could contain both text and an image, so stripping out p tags is not a solution.

    Images should not be wrapped in p tags.

    This has been an issue for over 5 years!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies