[TYPO3-doc] code highlighting

François Suter fsu-lists at cobweb.ch
Sat Sep 29 21:53:29 CEST 2012


Hi Martin,

There seems to be quite a bit of weirdness at work here.

> Reading in the Sphinx mailing list I just stumbled over two hints.
>
> It looks like that there is a highlight language "guess". Should work
> like:
>
> .. highlight:: guess

Yes, this helps. It performed proper syntax highlighting for a PHP code 
sample declared with just "::".

OTOH a JavaScript sample declared with ".. code-block:: javascript" 
still does not get highlighted (but see below).

And a HTML snippet declared with ".. code-block:: html" worked already 
before.

> And another guy was complaining that highlighting didn't work. Reason my
> be that Sphinx and/or Pygments does some kind of syntax check on the
> code block. So that may be a reason to fail!

That could be, because I got the PHP sample to be properly highlighted 
also by adding PHP opening and closing tags ("<?php ... ?>") to my code 
sample.

And then I made some more tests. By making my JS sample longer, I could 
get it highlighted. And then I shortened it again, and it stayed 
highlighted. So well, some black magic at work apparently. But it 
globally works. I'm going to change the "highlight" directive to "guess".

That made me discover some cool options described in [1] (:linenos: and 
:emphasize-lines:), which I'm going to add to the examples.

Cheers

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch

[1] http://sphinx.pocoo.org/markup/code.html#line-numbers


More information about the TYPO3-project-documentation mailing list