5

I am developing a website in umbraco, the problem is when i insert my html in rich text editor it automatically inserts "p" (Paragraph Tag) tag in the html which is destroying my design.Please help me, i am stuck here.

Thank you.

DevUsman
  • 151
  • 2
  • 10

5 Answers5

6

How are you adding the page field onto your markup? Through a view or as a pagefield?

If you're adding it as a pagefield add the attribute stripParagraph="true"

If you're adding in a view then you could try

Html.Raw(library.RemoveParagraphTags(Model.bodyText.ToString()))

But that will only remove the first one

You could roll your own version of that method to remove all P tage, or try what's suggested here - http://scottsdevblog.com/2011/08/get-rid-of-those-pesky-p-tags-in-umbracos-tinymce-editor/

Carl Sargunar
  • 577
  • 1
  • 5
  • 15
  • Should add - I've not tried what Scott suggests, I would typically use a Simple Editor or Textbox Multiple data type if I didn't want P tags (which might also work for you) – Carl Sargunar Dec 17 '13 at 15:10
1

The OP asked how to stop the paragraph tags from being inserted. All of the proposed answers fail to prevent the insertion; they just try to mitigate its existence.

In your \config\tinyMceConfig.config, set forced_root_block to false.

<customConfig> ... <config key="force_p_newlines">false</config> <config key="forced_root_block">false</config> ... </customConfig>

LeeC
  • 331
  • 2
  • 12
0

Use @Html.Raw(richtexteditor.itsvalue) or check the html agility pack on nuget.

antao
  • 767
  • 1
  • 9
  • 24
0

I realise this is an old question but I have had some trouble with this issue too and have a neat little solution that I wanted to share.

I tried changing / removing the forced_root_block and using Raw HTML, neither of which really worked well for me.

Instead I wrapped the output of the field in a semantic tag () and then added a css rule:

mce p:first-of-type {
    margin-top:0px;
}

mce p:last-of-type {
    margin-bottom:0px;
}

For me, this felt less 'hacky' and didn't require me to keep any customised versions of files or output mark-up in the Raw format.

Hope this helps someone else :)

Craig Poole
  • 740
  • 8
  • 19
0

Umbraco 7, Razor

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

atazmin
  • 4,757
  • 1
  • 32
  • 23