sos-notebook
sos-notebook copied to clipboard
How to add colors to github preview
Our notebook, particularly when containing long scripts, can be a bit ugly. Even though those with shorter scripts are fine.
But other notebooks on github seems to show better:
https://github.com/geekypete/Genomic-Prediction/blob/master/GenomicPrediction.ipynb
Are there some .gitattributes
we can customize and provide?
Syntax highlighting is a tricky business.
We use codemirror for live editing and went a long way to support multiple kernels especially %expand
and action: expand
.
Github uses nbconvert to convert notebooks to static HTML (no js) for preview. nbconvert uses pygments. We do support pygments and install sos pygment parser by default, but github does not have our pygments plugin, so it cannot handle sos notebook. We could potentially improve our parser (https://github.com/vatlab/SoS/issues/161) and submit it to upstream (so that it can be bundled), but it will be a lot of work to handle multiple parsers and %expand as we did for codemirror. Actually, we have now two options to generate HTML, one using pygments and one using codemirror (the cm
templates), and I generally prefer the codemirror one because it is consistent with what users see when they edit the notebook.
For github to display .sos files correctly, we need to implement a textmate parser and ask github to adopt sos as an officially supported language (see https://github.com/vatlab/SoS/issues/967 for details).
https://github.com/neeksandhu/codemirror-textmate