Skip to content

TextformatterSmartypants incompatible with TextformatterEntities #17

@Toutouwai

Description

@Toutouwai

Briefly describe the issue.

TextformatterSmartypants transforms "dumb" typography into "smart" typography, encoded as HTML entities. But it doesn't convert all necessary characters to entities (e.g. >) so it often needs to be used in conjunction with TextformatterEntities. But this results in either:

  • the double-encoding of ampersands (Smartypants before Entities)
  • or dumb typography (Entities before Smartypants)

What did you expect to happen?

TextformatterSmartypants and TextformatterEntities are able to be used together with normal functionality for each textformatter.

What did actually happen?

  • the double-encoding of ampersands (Smartypants before Entities)
  • or dumb typography (Entities before Smartypants)

Optional: Do you have screenshots/links that demonstrate the issue?

Bad:
sp-1
Also bad:
sp-2

Optional: Have you a suggestion for a possible fix?

The simplest fix would be to decode entities coming from Smartypants. In TextformatterSmartypants.module:

public function format(&$str) {
    require_once(dirname(__FILE__) . "/smartypants.php"); 
    // original
    // $str = \SmartyPants($str);

    // fixed
    $str = html_entity_decode(\SmartyPants($str));
}

Alternatively each entity in smartypants.php could be replaced with its UTF-8 equivalent.

What are the steps to reproduce the issue?

  1. Apply both TextformatterSmartypants and TextformatterEntities to the same field, which contains dumb quotes.
  2. Check the result of the textformatters on the front-end.

Tell us about the setup you experienced the bug in.

  • ProcessWire version: 3.0.35

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions