cython/cython — pull request #257 by Carreau (2013-09-24 13:19:54+00:00)
Title: Clean html-annotate generation

Following discussion on [user-Ml](https://groups.google.com/forum/#!topic/cython-users/hO71JDjZENs)

And should fix https://github.com/ipython/ipython/issues/4028

Issues was that css style from generated html for annotated generated cython was leaking into the page when embeded and/or conflicting, which was annoying in IPython notebook for example.

Fix was to force style to only apply if and only if the targeted tags are situated into a common parent tag that have a `.cython_out` css class.

I used this excuse to slightly refactor the generation of html into sub-step.

- one function return the css
- one function return the javascript
- one function return the html-annotated code
- one return the full html

So now `save_annotation` just have to assemble and write to file instead of intermixing logic + io.

There should be only one significant difference for small snippet of code; instead of hardcoding the yellow highlight in each `style` tag for each line, I'm generating 256 css class `.score_000` to `.score_255` that are applied to the html. This should allow much easier custom theming in future, but then for small snippet the html file grow by ~250 lines.

There is still one think that might need to be fixed is that multiple embedded snippet conflict on line number when one want to toggle the view of the generated code (should be easy, but will do in another PR).

I'm not used to work with python 2.4 to 2.6 compatibility so I hope I haven't missed anything when writing this.

Thanks.