Skip to content

Possible bug in the readme example (entityToHTML)Β #179

@Nasicus

Description

@Nasicus

The readme has the following example:

  entityToHTML: (entity, originalText) => {
    if (entity.type === 'LINK') {
      return <a href={entity.data.url}>{originalText}</a>;
    }
    return originalText;
  }

This works fine, however the originalText appears to be already HTML encoded and therefore if it contains special characters like an ' it will be double encoded.

E.g. originalText = my&#x27;url will result in the HTML <a href="https://google.ch">my&amp;#x27;url</a>

As a workaround I changed the function to that:

    if (entity.type === 'LINK') {
      return <a href={entity.data.url} />;
    }

    return originalText;

Now the resulting HTML will be <a href="https://google.ch">my&#x27;url</a> (because of the way the getElementHTML function works).

Not sure if this workaround is correct and can be used like this but it appears to work. I guess if the getElementHTML will never change I can leave my workaround...

Also not sure if I'm doing something wrong or if this is an actual bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions