• Resolved jocca

    (@jocca)


    Is it a bug? Should I create a ticket in trac?

    The error was observed with German locale (‘de’).

    Expected behavior:

    echo wptexturize('"Test"'); // \&\#8222;Test\&\#8220; => ?Test“
    echo wptexturize('"<a>Test</a>"'); // \&\#8222;<a>Test</a>\&\#8220; => ?Test“ (with hyperlink)

    Observed behavior:

    echo wptexturize('"Test"'); // \&\#8222;Test\&\#8220; => ?Test“
    echo wptexturize('"<a>Test</a>"'); // \&\#8222;<a>Test</a>\&\#8222; => ?Test? (with hyperlink)

    The change is in the last line, the last character: After the closing tag the closing double quotation mark is replaced by the wrong character.

    • This topic was modified 2 years, 2 months ago by jocca. Reason: formatting

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    It looks like the problem is long standing and not unique to the German locale.
    https://core.trac.www.ads-software.com/ticket/18549

    Texturize doesn’t work well with quoted inline HTML tags. As a workaround, have you tried inserting \&\#hairsp; between quotes and HTML tags? The extra hair space shouldn’t appear too obtrusive. Better than the wrong quote char at least.

    Thread Starter jocca

    (@jocca)

    thanks for the link!

    I think some regex filter added to the_content might also work, as long this bug is not fixed upstream.

    Thread Starter jocca

    (@jocca)

    This filter resolves the described bug, but not all cases described in the trac ticket above.

    add_filter('the_content', function($content) {
      return preg_replace("/(<\/\w+>)\&\#8222;(\S)/u", "$1“$2", $content);
    });
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug in wptexturize(): wrong quotation mark after closing tag’ is closed to new replies.