mhucka
mhucka

Reputation: 2399

How to make Doxygen do syntax highlighting in @code containing XML fragments?

I'm documenting a software library that manipulates an XML data format. I'd like to be able to write examples of XML in the documentation, and the natural way to do that would be

@code{.xml}
... xml here ...
@endcode

except that Doxygen does not do syntax highlighting on the contents like it does for other content such as C++. (I've tried .html instead of .xml in there too, in case Doxygen supported HTML but not XML, but Doxygen doesn't seem to recognize either one.)

Does anyone have any suggestions for how to achieve syntax highlighting for XML code fragments?

(And while on the topic, where can I find a list of the languages that Doxygen does recognize and highlight in @code/@endcode blocks? I have not found it in the Doxygen manual so far.) Assuming that Doxygen can only do syntax highlighting for the languages it can parse (which are listed for the variable EXTENSION_MAPPING, as pointed out by user "albert" in the comments below), then this implies the need for some external preprocessing. Does anyone have suggestions for a clever way to do this?

Upvotes: 3

Views: 6276

Answers (1)

Michael Repucci
Michael Repucci

Reputation: 1663

For others, like me, who may come across this many years after the original post, Doxygen supports syntax highlighting of the languages it supports via Markdown Extensions. Just use the Fenced Code Blocks or the \code command with the explicit file extension specified.

I also found a Javascript library that can be used with Doxygen, but I haven't actually tried it.

Upvotes: 3

Related Questions