What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

Now that syntax highlighting hints have now been implemented, I've been going through the answers I can remember that did not have syntax highlighting (due to the tags) and add the hints. However, I noticed that you cannot apply the same override twice in a post in different blocks. It will only be applied to the first block only but not on any others. Multiple hints could be applied as long as they are all different apparently. Looking at the source HTML confirms this.

Here I have 3 blocks (4 including my test block I just added, but now reverted), (cs) cs xml cs: LINQ to XML selection/update

<pre class="lang-cs prettyprint-override"><code>//short test block
</code></pre>

<pre><code>// load the XML document
...
</code></pre>

<pre class="lang-xml prettyprint-override"><code>
...
</code></pre>

<pre><code>var xpath = "/main/videos/video/*[starts-with(name(.),'date')]";
var query = doc.XPathSelectElements(xpath);
</code></pre>

I added a test block since I thought that the length of the block affected what gets highlighted. The length doesn't appear to affect it, but then all other C# blocks do not get highlighted anymore as I mentioned.

Here I have 2 blocks, cs cs: LINQ to XML select multiple elements?

On Meta Stack Overflow on the formatting sandbox, cs java cs html default: Formatting Sandbox

<pre class="lang-cs prettyprint-override"><code>// C#
var x = 1 + 2;
x = FooBar();
</code></pre>

<pre><code>// Java
int x = 1 + 2;
x = FooBar();
</code></pre>

<pre><code>// C# again
var x = 1 + 2;
x = FooBar();
</code></pre>

<pre class="lang-html prettyprint-override"><code>&lt;!-- html comment! --&gt;
</code></pre>

<pre class="lang-default prettyprint-override"><code>// C# again as lang-default
var x = 1 + 2;
x = FooBar();
</code></pre>

(Seeing as the prettify code classes C# and Java as similar languages, Java doesn't get the hints applied)

I included hints for the HTML code blocks above, and you should see that the second doesn't get prettified as well. But it does show as highlighted in the edit views. A workaround would be to choose one of them to be lang-default, but that would only work once, and the auto selected language could be wrong.

Could this be fixed?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

After our next deploy we will support multiple code block lang-* prettify hints that have the same name. Nice catch!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .