4

While answering a question I noted the styling for XML code blocks on DBA.SE is significantly less readable than the one from SO. For a comparison see this rendering of the same fragment:

screenshot of syntax highlighting

On the SO version, there's four distinguishable colors in use, whereas DBA only has two (or three, if you count the blue for the <> characters).

If it's just a small thing to do, I'd request the coloring for the DBA version would provide more contrast, especially to distinguish elements (e.g. <p1:ReportName>) from their text content (e.g. SomeAwesomeSubreport).


Note that I used a language markup hint to force XML styling. You can see my answer here on DBA, but for SO I just used the "preview" when asking a question to take the screenshot. The code snippet from the screenshots looks like this:

<!-- language: xml -->

    <p1:Subreport xmlns:p1="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" Name="SubReport">
      <p1:ReportName>SomeAwesomeSubreport</p1:ReportName>
      <p1:Parameters>
        <p1:Parameter Name="Param1">
          <p1:Value>=Fields!MyGreatField.Value</p1:Value>
        </p1:Parameter>
      </p1:Parameters>
      <p1:KeepTogether>true</p1:KeepTogether>
      <p1:Height>2.25cm</p1:Height>
      <p1:Width>21cm</p1:Width>
      <p1:Style />
    </p1:Subreport>
5

A given question tag will specify markup to be used throughout the question (there are rules, but effectively the first "language specified tag" will set the tone for the entire page), but to override that for a specific answer, or portion of a question (as you're demonstrating in the linked bits) you would need to refer to the aforementioned question:

Syntax highlighting language hints

The proper way to use this is to (in the case of XML hinting) use this before your code:

<!--language: lang-xml --> 

    <xml>
      <tag>
        text
      </tag>
    </xml>

Note the following two bits of information: The "language tag" is left with the margin, and the text is indented as for code spacing, and the use of "lang-" before the actual language identifier.

Cheers, HTH, YMMV

  • 2
    You need a blank line after the <!-- --> thing, otherwise the code block doesn't kick in. – Mat Oct 17 '12 at 5:41
  • Good point Mat, shame you can't edit meta posts >.< (at least, my recollection is no editing of meta posts in most circumstances - as a mod I don't have those restrictions here) – jcolebrand Oct 17 '12 at 13:00
  • 1
    Yep, it's "Suggested edits are not allowed on non-tag-wiki posts on meta sites" for us mere mortals. It's a torture for OCD editors like I am:) – Mat Oct 17 '12 at 13:15
  • Should be able to flag in the future ;-) – jcolebrand Oct 17 '12 at 15:23

You must log in to answer this question.

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