Annotate Code Blocks
You can annotate code blocks by using the calloutlist element and co elements. In the published output, the callouts act as clickable "hotspots" that highlight parts of the code. When someone selects a "hotspot", they are taken to the callout text explanation for that "hotspot".
For example, in the image below, the code sample has two callout "hotspots" labelled 1 and 2. Below the code sample, there are numbers that match the hotspots, and next to each number is an annotation that explains the purpose of the corresponding code.

To annotate code using calloutlist:
Select a position in the code block where you want a callout "hotspot" to appear.
Press Alt + Enter ⏎ (Windows) or Command ⌘ + Enter ⏎ (Mac) to display the Element Context Menu.

Select the
coelement and give it anxml:id valuein the Element attributes section. Eachcoelement has to have anxml:idvalue that is unique in that specific topic. For example, you could give the firstcoelement thexml:idid_1, the secondcoelement thexml:idid_2 and so on.Add a
calloutlistelement after theprogramlistingelement that contains your code block.Tip
It can be a good idea to include the
programlistingandcalloutlistelements inside anexampleelement, so that they are all in a single "container" (theexampleelement).Give each
calloutin thecalloutlistanxml:idas well, different from the ones in thecoelements, e.g "callout_1", "callout_2". Again, these ids need to be unique.Associate the
coelements with thecalloutelements:For each
coelement, add alinkendsattribute. Set the value of thelinkendsattribute to thexml:idvalue of thecalloutthat you want to associate it with.For each
calloutelement, add thearearefsattribute. Set the value of the arearefs attribute to thexml:idvalue of thecothat you want to associate it with.