-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
This has come up in a discussion about changing the markup of the PHP highlight_string()
and highlight_file()
functions.
My understanding is that the markup should be as follows:
<pre><code>
<?php
function foo() {
echo "Hello world";
}
?>
</code></pre>
And if one would to add syntactic colouring, one would go about by adding <span>
tags as follows:
<pre><code>
<span class="tag"><?php</span>
<span class="keyword">function</span> <span class="name">foo</span>() {
<span class="keyword">echo</span> <span class="string">"Hello world"</span>;
}
<span class="tag">?></span>
</code></pre>
However, the following MDN note:
The
<code>
element by itself only represents a single phrase of code or line of code.
Leads to the interpretation that the following markup is acceptable:
<pre>
<code class="tag"><?php</code>
<code class="keyword">function</code> <code class="name">foo</code>() {
<code class="keyword">echo</code> <code class="string">"Hello world"</code>;
}
<code class="tag">?></code>
</pre>
However, in the current living document there is no mention of doing the above and the examples provides for the <code>
tag and <pre>
tag only demonstrate using a single <code>
tag.
Moreover, the markup used by the living document follows the markup of using only one <code>
tag and using custom elements for individual pieces to syntactically highlight.
I think it would be a good idea to clarify more how the <code>
tag should be used. As the current specification seems to be lacklustre on details.