HTML Entity Issue

I’m having an odd issue where I can’t get an HTML Entity(registered trademark symbol ®) to render correctly.
We are using the cms-react templates to build this site. This particular field is using a TextField for the heading and passing that field into an “Island” component that is renderened on load.
This symbol renders properly locallly and ALSO in the preview when editing the page. However, when you view a preview of the page it renders as “\®”. Screenshots attached of the different scenarios.
Is there something different I need to do? I can provide more links and code examples if needed but curious if anyone has run into this?


Live preview while editing. Works fine.

Preview of the page, renders incorrectly.

Local development renders fine.

Hi @BMaier and welcome, we are so glad to have you here!
Thanks for reaching out to the HubSpot Community and sharing screenshots, it is easier to understand.
I’d love to put you in touch with our Top Experts and Community Members: Hi @nickdeckerdevs1, @ABainbridge, @KKuzmin, @mangelet and @Stephanie-OG do you have any tips to share with @BMaier, please?
Have a great day and thanks so much in advance for your help!
Bérangère

I couldn’t reproduce this. here’s my examples. I used Alt + 0174 for the registered icon

I then have my heading defined as this

We use a re-usable component for headings and descriptions on all of our modules
```js

import PropTypes from ‘prop-types’;

import React from ‘react’;

import { getTextAlignClass, getTextColorClass } from ‘../../utilities/styleHelpers.js’;

const DynamicHeading = ({ headings }) => {

return (

<div data-testid=“dynamicheading-container” id=“dynamicheading-div-1-1”>

{headings?.map((item, index) => (

<div

className={`${getTextAlignClass(item.heading_align)} ${getTextColorClass(

item.heading_color,

)}`}

key={item.heading}

data-testid={`dynamicheading-item-${index}`}

id={`dynamicheading-div-2-2-${index}`}

>

{React.createElement(item.heading_size, {}, item.heading)}

</div>

))}

</div>

);

};

DynamicHeading.displayName = ‘DynamicHeading’;

DynamicHeading.propTypes = {

headings: PropTypes.arrayOf(

PropTypes.shape({

heading: PropTypes.string.isRequired,

heading_align: PropTypes.string,

heading_color: PropTypes.string,

heading_size: PropTypes.string.isRequired,

}),

).isRequired,

};

export default DynamicHeading;

```

this is inside of the fields file that is exported by my island, or rather the module that holds the island

```js

export const featureAuthoringGroup = {

type: ‘group’,

name: ‘featureAuthoringGroup’,

label: ‘Feature authoring form’,

expanded: true,

children: [

getDynamicHeadingField(‘featureAuthoring’),

getDynamicDescriptionField(‘featureAuthoring’),

],

};

```

then I have this helper function to get around issues with having the same field definitions within a single module. eg I can have headings and descriptions on a component, and then if there’s say a modal, I can give the modal it’s own heading and description

```js

/**

* Generates a HubSpot field group configuration for a dynamic heading component.

* This group allows content editors to specify the heading text, size (H1-H6, P), color, and alignment.

*

* @param {string} [headingIdPrefix=‘’] - An optional prefix to prepend to the IDs of the fields within the group.

* Useful for ensuring uniqueness when this group is nested or repeated.

* @returns {object} A HubSpot field group definition object.

*/

export const getDynamicHeadingField = (headingIdPrefix = ‘’) => {

let prefix = headingIdPrefix;

if (prefix.length > 0) {

prefix += ‘.’;

}

return {

children: [

{

allow_new_line: false,

default: ‘Enhanced User Experience’,

display_width: null,

id: `${prefix}heading.heading`,

label: ‘Heading’,

locked: false,

name: ‘heading’,

required: false,

show_emoji_picker: false,

type: ‘text’,

validation_regex: ‘’,

},

{

choices: [

[‘h1’, ‘H1’],

[‘h2’, ‘H2’],

[‘h3’, ‘H3’],

[‘h4’, ‘H4’],

[‘h5’, ‘H5’],

[‘h6’, ‘H6’],

[‘p’, ‘P’],

],

default: ‘h2’,

display: ‘select’,

display_width: ‘half_width’,

help_text: ‘HTML heading size’,

id: `${prefix}heading.heading_size`,

label: ‘Size’,

locked: false,

multiple: false,

name: ‘heading_size’,

preset: null,

reordering_enabled: true,

required: true,

type: ‘choice’,

},

{

choices: colourChoices,

default: ‘primary’,

display: ‘select’,

display_width: null,

id: `${prefix}heading.heading_color`,

label: ‘Color’,

locked: false,

multiple: false,

name: ‘heading_color’,

preset: null,

reordering_enabled: true,

required: true,

type: ‘choice’,

},

{

choices: [

[‘auto’, ‘Auto’],

[‘left’, ‘Left’],

[‘center’, ‘Center’],

[‘right’, ‘Right’],

],

default: ‘auto’,

display: ‘select’,

display_width: null,

id: `${prefix}heading.heading_align`,

label: ‘Align’,

locked: false,

multiple: false,

name: ‘heading_align’,

preset: null,

reordering_enabled: true,

required: true,

type: ‘choice’,

},

],

display_width: null,

expanded: false,

group_occurrence_meta: null,

id: `${prefix}heading`,

label: ‘Heading’,

locked: false,

name: ‘heading’,

occurrence: {

default: 0,

min: 0,

},

required: false,

tab: ‘CONTENT’,

type: ‘group’,

};

};

```

This is what I’m experiencing as well. It shows up as expected when editing the page BUT when previewing the page or publishing the page it doesn not work. Can you confirm that?

Look at the screenshot above the code examples. It’s working fine in that scenario with that code. you mentioned HTML Entity, what is this? you can use alt + numbers to do symbols like this that work

Apologies. I didn’t see the “when published” bit previously. here’s my page after publishing and using alt + whatever number it was

Hi. I solved the same problem using the “decode” method of the “he” library.

For example

import "he";

const heading = he.decode(tab.heading)

This should help with your problem.

Will try this!