Disable auto-adding of <p> tag

Jakolcz picture Jakolcz · Jul 31, 2013 · Viewed 14.1k times · Source

I'm trying to remove auto-adding of <p> tag in CQ5(Version 5.6.0.20130125). I've tried to add these properties to the text component I'm using but with no effect.(source)

removeSingleParagraphContainer   true
singeParagraphContainerReplacement    (empty string)

I've also tried this solution. Again, no effect.

Is it possible to disable auto-adding of <p> tag?

Thanks for any ideas

EDIT I've tried this answer but CQ still adds <p> tags to my code. For example, I have this HTML code

<strong>Headquarters:</strong>
<p>MY - COMPANY a.s.<br>
Random Street 77<br>
Random City</p>

and after I submit it, the code changes to

<p><strong>Headquarters:</strong></p>
<p>MY - COMPANY a.s.<br>
Random Street 77<br>
Random City</p>

my RTE looks like this

<text jcr:primaryType="cq:widget"
      hideLabel="{Boolean}true"
      name="./text"
      xtype="richtext">
  <htmlRules jcr:primaryType="nt:unstructured">
      <docType jcr:primaryType="nt:unstructured">
          ...
      </docType>
      <blockHandling
          jcr:primaryType="nt:unstructured"
          removeSingleParagraphContainer="{Boolean}true"/>
  </htmlRules>
</text>

EDIT2 this is what my hierarchy looks like enter image description here

Answer

mszu picture mszu · Jul 31, 2013

You can keep the RTE from surrounding your text with <p> tags by setting the removeSingleParagraphContainer property to true as long as you only create one paragraph.

With Chrome on Mac OS X (at least), holding shift while pressing enter inserts line breaks instead of paragraph breaks so you can still create text with multiple lines. Since you said in your last question that you're using the misctools plugin, you can use the source edit view to peek at the markup as you go.

Finally, to set the removeSingleParagraphContainer property, you'll need to create another child called blockHandling under your htmlRules node in your dialog. You don't need to mess with singeParagraphContainerReplacement property, but if you did, you would set it on the same node:

<rtePlugins jcr:primaryType="nt:unstructured">
    ...
</rtePlugins>
<htmlRules jcr:primaryType="nt:unstructured">
    <docType jcr:primaryType="nt:unstructured">
        ...
    </docType>
    <blockHandling
        jcr:primaryType="nt:unstructured"
        removeSingleParagraphContainer="{Boolean}true"/>
</htmlRules>

Edit regarding your edit: using the source edit feature of the misctools plugin and pasting this exact text saves and loads without p tags for me in Chrome on Mac OS X:

<strong>Headquarters:</strong><br>
MY - COMPANY a.s.<br>
Random Street 77<br>
Random City

Are you sure your dialog.xml deployed properly? Maybe double-check that your component's dialog hierarchy looks how you'd expect it to in CRXDE Lite:

CRXDE Lite text nodes