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

帅比萌擦擦* 提交于 2019-12-02 02:05:59

问题


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


回答1:


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




回答2:


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)



来源:https://stackoverflow.com/questions/17946117/strong-tag-getting-replaced-to-b-tag-in-cq5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!