[wp-trac] [WordPress Trac] #58028: WP_HTML_Tag_Processor: Its reference in the Developer Resources is broken
WordPress Trac
noreply at wordpress.org
Sat Apr 1 19:28:24 UTC 2023
#58028: WP_HTML_Tag_Processor: Its reference in the Developer Resources is broken
--------------------------+---------------------
Reporter: juanmaguitar | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.2.1
Component: HTML API | Version: 6.2
Severity: normal | Resolution:
Keywords: | Focuses: docs
--------------------------+---------------------
Comment (by coffee2code):
This is actually the result of a few things.
The use of code fences ({{{```php}}} ... {{{```}}}) in inline docs is
prominent with the newly introduced `WP_HTML_Tag_Processor` and is just
about the only usage in core. There is one preexisting case for
[https://developer.wordpress.org/reference/classes/wp_theme_json/get_metadata_boolean/
WP_Theme_JSON::get_metadata_boolean()], which was introduced in WP 6.0 and
also exhibits this issue.
Both the [https://github.com/wordPress/phpdoc-parser phpdoc-parser] and
the [https://github.com/WordPress/wporg-developer DevHub theme] recognize
the Markdown conversion of the beginning of a code block when it becomes
`<pre><code>`. But by the code fence specifying the language, it results
in the language being explicitly added to the resultant markup, e.g.
`<pre><code class="language-php">` which is different than what is
expected. This results in:
1. The parser [https://github.com/WordPress/phpdoc-
parser/blob/master/lib/runner.php#L156 fails to recognize the code block]
and thus does not preserve its newlines.
2. The theme [https://github.com/WordPress/wporg-
developer/blob/trunk/source/wp-content/themes/wporg-developer-2023/inc
/template-tags.php#L1719 fails to recognize the code block] and thus fails
to replace the `<pre><code class="language-php">` opening tags with the
opening `[code lang="php"]` shortcode, but ''does'' replace the closing
`</code></pre>` with `[/code]`, resulting in unbalanced markup and the
code shortcode not being invoked.
Both pieces of code can of course be updated, and I think that'll do it.
It'll then require a reparsing. Things are slightly complicated by the
fact that the !DevHub theme isn't currently running its repo's trunk.
So this is probably more a meta.trac ticket than core.trac. Core ''could''
use simple code fences that don't specify 'php' which would "fix" things
after a reparsing without any code changes, but ideally the parser and the
theme should accommodate such syntax.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58028#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list