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

notebook -- make it so foo?? in the notebook shows the source code syntax highlighted #3953

Closed
williamstein opened this issue Aug 26, 2008 · 1 comment

Comments

@williamstein
Copy link
Contributor

Here's some relevant code by Gabriel Gellner -- a diff to server/support.py -- to this problem:

teragon-2:Downloads was$ diff ~/d/sage/sage/server/support.py support.py 
23a24,29
> from pygments import highlight
> from pygments.lexers import PythonLexer
> from pygments.formatters import HtmlFormatter
> 
> 
> 
218,220c224,228
<         src = sagedoc.format_src(src)
<         if not lineno is None:
<             src = "File: %s\nSource Code (starting at line %s):\n%s"%(filename, lineno, src)
---
>         #Slicing of the first 95 characters is a kluge to get rid of the doctype,
>         # really we should write our oun HtmlFormatter
>         src = highlight(src, PythonLexer(), HtmlFormatter(full=True))[94:]
>         #if not lineno is None:
>         #    src = "File: %s\nSource Code (starting at line %s):\n%s"%(filename, lineno, src)

This requires the pygments library to be installed. Also, the notebook will have to be
changed to not escape <'s etc. in the output of the source code window.

Component: notebook

Issue created by migration from https://trac.sagemath.org/ticket/3953

@williamstein williamstein added this to the sage-4.1.1 milestone Aug 26, 2008
@qed777 qed777 mannequin changed the title notebook -- make it so foo?? in the notebook shows the source code syntax highlighted [duplicate of #5653, should be closed] notebook -- make it so foo?? in the notebook shows the source code syntax highlighted Aug 10, 2009
@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Aug 12, 2009

comment:2

This is a duplicate of #5653. Close it as per Mitesh Patel's suggestion.

@sagetrac-mvngu sagetrac-mvngu mannequin closed this as completed Aug 12, 2009
@sagetrac-mvngu sagetrac-mvngu mannequin removed this from the sage-4.1.1 milestone Aug 12, 2009
@sagetrac-mvngu sagetrac-mvngu mannequin added r: duplicate and removed p: major / 3 labels Aug 12, 2009
@sagetrac-mvngu sagetrac-mvngu mannequin changed the title [duplicate of #5653, should be closed] notebook -- make it so foo?? in the notebook shows the source code syntax highlighted notebook -- make it so foo?? in the notebook shows the source code syntax highlighted Aug 12, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants