5

I often find myself wanting to draw attention to a particular part of the contents of a code block. The italic and bold formatting is interpreted literally, so those don't work:

_italic_ *bold*

I understand that under most circumstances we want code blocks to show exactly what is represented, but it would be nice to have some sort of markup that does work inside code blocks, for example if I wanted to highlight ANSWER: 0 here:

; <<>> DiG 9.7.0-P1 <<>> @a.gtld-servers.net ns1.google.com a
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25337
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 4
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;ns1.google.com.            IN  A

;; AUTHORITY SECTION:
google.com.     172800  IN  NS  ns2.google.com.
google.com.     172800  IN  NS  ns1.google.com.
google.com.     172800  IN  NS  ns3.google.com.
google.com.     172800  IN  NS  ns4.google.com.

;; ADDITIONAL SECTION:
ns2.google.com.     172800  IN  A   216.239.34.10
ns1.google.com.     172800  IN  A   216.239.32.10
ns3.google.com.     172800  IN  A   216.239.36.10
ns4.google.com.     172800  IN  A   216.239.38.10

;; Query time: 137 msec
;; SERVER: 192.5.6.30#53(192.5.6.30)
;; WHEN: Thu Apr 14 13:27:58 2011
;; MSG SIZE  rcvd: 164

It would be nice to be able to use something like the language hinting to specify what text should be highlighted in the following code block:

<!-- highlight: "ANSWER: 0" -->

1 Answer 1

2

The idea of trying any kind of language identification in the code blocks has been discussed before. What it boils down to is that it just doesn't work at all well for the kinds of things that get posted on SF.

As for highlighting a section of the code, that is bound to create problems. Due to the diversity of the stuff posted on SF it's almost inevitable that any kind of markup within the code block will clash with something someone wants to post (but I'd gladly be proven wrong). However, it's easy enough to break up the code and insert comments a desired. e.g.

; <<>> DiG 9.7.0-P1 <<>> @a.gtld-servers.net ns1.google.com a
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25337

ANSWER 0 is the bit I want to point out:

;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 4
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;ns1.google.com.            IN  A

;; AUTHORITY SECTION:
google.com.     172800  IN  NS  ns2.google.com.
google.com.     172800  IN  NS  ns1.google.com.
google.com.     172800  IN  NS  ns3.google.com.
google.com.     172800  IN  NS  ns4.google.com.

;; ADDITIONAL SECTION:
ns2.google.com.     172800  IN  A   216.239.34.10
ns1.google.com.     172800  IN  A   216.239.32.10
ns3.google.com.     172800  IN  A   216.239.36.10
ns4.google.com.     172800  IN  A   216.239.38.10

;; Query time: 137 msec
;; SERVER: 192.5.6.30#53(192.5.6.30)
;; WHEN: Thu Apr 14 13:27:58 2011
;; MSG SIZE  rcvd: 164
1
  • I'm not really interested in syntax highlighting; what I want to do is much simpler: just highlight part of the code block. The syntax highlighting hinting linked from the other meta was a good example of avoiding markup clashes since identifying what you want to highlight is external to the code block, avoiding any issues with unintentional markup.
    – Cakemox
    Commented Apr 14, 2011 at 15:07

You must log in to answer this question.

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