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

aem, html, tags

Solution

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):

Problem

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

Original source