Skip to content

Regression: highlight_string() HTML still lacks Zend <pre> wrapper / uses nbsp (re-#10308, ext/standard/highlight.c) #23733

Closed

Description

@PurHur

Category

Stdlib · php-src-strict · highlight_string · pillar 4

Problem

highlight_string('<?php echo 1;', true) still diverges from Zend markup. #10308 / #12401 closed earlier; still red on master 2026-07-27 vs Zend 8.4.23.

Repro Zend 8.4 VM
outer wrapper <pre><code style="color: #000000">…</code></pre> <code><span style="color: #000000">… (no <pre>)
spaces in spans literal space after php / echo &nbsp;
structure single-line spans inside <pre><code> nested color span + newlines

php-src reference

PHP implementation target

  • ext/standard/ highlight implementation — match Zend wrapper (<pre><code style=…>), span colors, and space (not &nbsp;) emission for this input
  • PHP-in-PHP; keep tokenizer path without growing runtime/ C

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/hl.php <<'"'"'PHP'"'"'
<?php
echo highlight_string("<?php echo 1;", true), "\n";
PHP
php bin/vm.php /tmp/hl.php'
# Compare to: docker run --rm -i \$HARNESS_DOCKER_RUN_OPTS --entrypoint php php:8.4-cli /dev/stdin < /tmp/hl.php

Done when

  • highlight_string(..., true) byte-matches Zend 8.4 for the <?php echo 1; smoke (wrapper + spaces)
  • highlight_file / show_source stay consistent with the same emitter
  • Compliance .phpt under test/compliance/cases/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 27, 2026
  2. PurHur commented on Jul 27, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #23733, #23731)

  3. PurHur commented on Jul 27, 2026

    @PurHur
    OwnerAuthor

    Merged in #23767.

    Verification: highlight_string('<?php echo 1;', true) byte-matches php:8.4-cli (no &nbsp;, <pre><code style=…> wrapper). PHPUnit highlight_string_pre_wrapper, highlight_file_br, highlight_file_multiline_br green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions