sos-notebook icon indicating copy to clipboard operation
sos-notebook copied to clipboard

How to add colors to github preview

Open gaow opened this issue 6 years ago • 2 comments

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?

gaow avatar Nov 07 '18 21:11 gaow

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).

BoPeng avatar Nov 07 '18 23:11 BoPeng

https://github.com/neeksandhu/codemirror-textmate

BoPeng avatar Dec 29 '18 16:12 BoPeng