Jakolcz
Jakolcz

Reputation: 564

<strong> tag getting replaced to <b> tag in CQ5

I'm using Rich Text Editor with MiscTools plugin to edit text in my website but when I open the HTML editor and create sth like this

<p><strong>Strong text</strong></p>

the CQ immediatelly rewrites it to

<p><b>Strong text</b></p>

Is it possible to disable this behaviour? I need to use the <strong> tag because of my CSS styles.

I'm using copy of text component from /libs/foundation/components/text.

Thanks for any help

Upvotes: 2

Views: 3410

Answers (2)

BGrand
BGrand

Reputation: 11

in semanticMarkupMap, add property "strong" with value "b" to automatically replace tags with in your rte text (and "em" property with value "i" for italic)

Upvotes: 1

mszu
mszu

Reputation: 413

There isn't very much documentation around this, but the default htmlRules configuration is eating your tags as part of its DOM processing/clean-up.

In particular, the defaults for the HtmlRules.DocType semanticMarkupMap (part of the typeConfig configuration property) will change <em> tags to <i> tags and <strong> tags to <b> tags.

I don't know if you can disable this directly, but you can update the map with an identity mapping (i.e. map b tags to b tags) so that nothing gets changed.

Add an htmlRules node like the following to your dialog.xml (as a sibling of the rtePlugins node):

...
<rtePlugins jcr:primaryType="nt:unstructured">
  ...
  <misctools
    jcr:primaryType="nt:unstructured"
    features="sourceedit"/>
</rtePlugins>
<htmlRules jcr:primaryType="nt:unstructured">
  <docType jcr:primaryType="nt:unstructured">
    <typeConfig jcr:primaryType="nt:unstructured">
      <semanticMarkupMap jcr:primaryType="nt:unstructured"
        b="b" 
        i="i"/>
    </typeConfig>
  </docType>
</htmlRules>
...
...

or you can add nodes directly to your dialog in CRXDE Lite if you're not using maven or something similar (this screenshot shows the default, unmodified <i> to <em> mapping -- don't forget to change that if that's not what you want):

CRXDE Lite node view

Upvotes: 9

Related Questions