Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting of python 2 notebooks not working on readthedocs #27

Closed
aebrahim opened this issue Feb 24, 2016 · 8 comments
Closed

Comments

@aebrahim
Copy link
Contributor

I'm not sure if this is the appropriate place for this, so feel free to close if it's not.

On readthedocs, I don't get syntax highlighting (conf file): http://cobrapy-test.readthedocs.org/en/latest/getting_started.html#Reactions

image

However, I do get syntax highlighting when I make the docs locally

image

@mgeier
Copy link
Member

mgeier commented Feb 25, 2016

I'm not sure what's the problem, because it works fine on the nbsphinx pages: http://nbsphinx.readthedocs.org/en/latest/code-cells.html.

You could try to add Pygments as a dependency to your requirements.txt.
Or probably it's just enough to "wipe" your build on RTD and re-build it again?

@aebrahim
Copy link
Contributor Author

I figured it out. For some reason this bug affects notebooks run in python 2. The notebook needs to have "pygments_lexer": "ipython3" instead of ipython2.

I am changing the issue title to reflect this.

@aebrahim aebrahim changed the title Syntax highlighting not working on readthedocs Syntax highlighting of python 2 notebooks not working on readthedocs Mar 14, 2016
aebrahim added a commit to aebrahim/cobrapy that referenced this issue Mar 15, 2016
This is done instead of converting them to rst first with nbconvert.

The notebooks also needed to be run in IPython 3 to work around
spatialaudio/nbsphinx#27
aebrahim added a commit to aebrahim/cobrapy that referenced this issue Mar 15, 2016
This is done instead of converting them to rst first with nbconvert.

The notebooks also needed to be run in IPython 3 to work around
spatialaudio/nbsphinx#27
aebrahim added a commit to opencobra/cobrapy that referenced this issue Mar 15, 2016
This is done instead of converting them to rst first with nbconvert.

The notebooks also needed to be run in IPython 3 to work around
spatialaudio/nbsphinx#27
@mgeier
Copy link
Member

mgeier commented Mar 15, 2016

Thanks for the update, I'm glad that it works now for you.

But I still don't know what the actual problem was ...
In your original example you are already using Python 3, but according to your screenshots this didn't work!
So why would it work now?

Did you happen to change the setting for the Python interpreter (2.x vs. 3.x) in the "Advanced Settings" on RTD (see point 4 here)?

Did you use or are you using 'IPython.sphinxext.ipython_console_highlighting' in extensions in your conf.py (see #24)?

@marius311
Copy link

I had the same issue as OP, syntax highlighting inside notebook cells OK on a local build, but not on RTFD. I fixed it by following the instructions in @mgeier's link, mainly adding IPython.sphinxext.ipython_console_highlighting to my extensions in conf.py (I also had to add ipython to requirements.txt).

I guess its unclear to me from the link if I'm supposed to have had to do this, but at least I can say that it worked.

Repo in question, if its useful to anyone: http://cosmoslik.readthedocs.io/

@mgeier
Copy link
Member

mgeier commented Aug 25, 2016

I think it should not be necessary to explicitly specify IPython.sphinxext.ipython_console_highlighting.
If everything works as intended, the lexer should be registered automagically when installing the IPython package.

@marius311 Probably just adding ipython to requirements.txt is enough?

@marius311
Copy link

Just checked and you're right, just ipython did it. Thanks.

@mgeier
Copy link
Member

mgeier commented Aug 27, 2016

Thanks for confirming that! I've added some documentation about it: http://nbsphinx.readthedocs.io/en/latest/usage.html#Syntax-Highlighting

@mgeier
Copy link
Member

mgeier commented Feb 7, 2017

LawrenceMMStewart pushed a commit to LawrenceMMStewart/jaxclust that referenced this issue Oct 20, 2023
…ighlighting to conf.py in order to try and get syntax highlighting in ipynb. see spatialaudio/nbsphinx#27
LawrenceMMStewart pushed a commit to LawrenceMMStewart/jaxclust that referenced this issue Oct 20, 2023
created docs with ipynb example, setups and requirements and github actions

added github action to deploy, probably will require need to debug

updated bug in github repo and username

updated workflow to deploy docs

debug for workflow

debug for workflow

debug for workflow

debug for workflow

debug for workflow

debug for workflow

debug for workflow

debug for workflow

debug for workflow

new action

added env ssh key

added gh_token to secrets

added gh_token to secrets

using cpina with SSH

changed deployment to https://cpina.github.io/push-to-another-repository-docs/sphinx-example.html

updated docs for push

ofuxed error in make and with touch

attempt now branch gh-pages exists:
g

docs --> /docs in target-directory

changed back target directory and source_directory now has docs/_

moved target directory to . to see if docs are detected in this fashion

moved target directory to . to see if docs are detected in this fashion

added ipython to requirements and IPython.sphinxext.ipython_console_highlighting to conf.py in order to try and get syntax highlighting in ipynb. see spatialaudio/nbsphinx#27

added pygments_lexer and as a extension in conf.py and as a requirement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants