npryce / code-guide Goto Github PK
View Code? Open in Web Editor NEWGenerate step-by-step explanations of code from special comments
Generate step-by-step explanations of code from special comments
When I try to convert the example file test.py
#|| Hello World
#|| ===========
#||
#|| Hello world is traditionally used to illustrate to beginners
#|| the most basic syntax of a programming language, or to verify
#|| that a language or system is operating correctly.
#| This is all that is required in Python
print "hello, world"
#|.
... on a fresh install of Python 3.3.1 via Homebrew on a Mac, the conversion stops when the actual code markup should begin. The generated HTML console output of code-guide test.py
is:
<html><head><title>Hello World</title><link rel="stylesheet" type="text/css" href="code_guide/bootstrap/css/bootstrap.min.css"></link><link rel="stylesheet" type="text/css" href="code_guide/bootstro.min.css"></link><link rel="stylesheet" type="text/css" href="code_guide/pygments.css"></link><link rel="stylesheet" type="text/css" href="code_guide/code-guide.css"></link><script type="text/javascript" src="code_guide/jquery-1.9.1.min.js"></script><script type="text/javascript" src="code_guide/bootstrap/js/bootstrap.min.js"></script><script type="text/javascript" src="code_guide/bootstro.min.js"></script><script type="text/javascript" src="code_guide/code-guide.js"></script></head><body><div class="code-guide-intro"><h1>Hello World</h1>
Hello world is traditionally used to illustrate to beginners the most basic syntax of a programming language, or to verify that a language or system is operating correctly.
Explain!
... and is followed by this runtime error:
File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 346, in cli
out=XMLGenerator(sys.stdout if use_stdio(args.output) else open(args.output, "w")))
File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 258, in to_html
_code_tree_to_html(out, e, code_lexer, md)
File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 142, in _code_tree_to_html
stream_html(out, pygments.highlight(" " if e.text == "" else e.text, code_lexer, HtmlFormatter(cssclass="", classprefix="code-guide-syntax-")))
File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 125, in stream_html
xml.sax.parseString(html_str, filter)
File "/usr/local/Cellar/python3/3.3.1/Frameworks/Python.framework/Versions/3.3/lib/python3.3/xml/sax/__init__.py", line 45, in parseString
inpsrc.setByteStream(BytesIO(string))
TypeError: 'str' does not support the buffer interface
Interestingly, after I re-installed Python and Pip and wanted to install code_guide
again, I got this on the console:
$ pip3 install code_guide
Downloading/unpacking code-guide
Running setup.py egg_info for package code-guide
Requirement already satisfied (use --upgrade to upgrade): markdown==2.3.1 in /usr/local/lib/python3.3/site-packages (from code-guide)
Requirement already satisfied (use --upgrade to upgrade): pygments==1.6 in /usr/local/lib/python3.3/site-packages (from code-guide)
Installing collected packages: code-guide
Running setup.py install for code-guide
File "/usr/local/lib/python3.3/site-packages/code_guide/test_code_guide.py", line 223
print e
^
SyntaxError: invalid syntax
changing mode of /usr/local/share/python3/code-guide to 755
Successfully installed code-guide
Cleaning up...
-- but only once.
I tried to install Pygments in a python 2.7.3 setup as a standard user (shared cluster, no root access), but it went bad and not pygmentize is also throwing an error.
The installation looks like:
$ pip install --index-url=https://pypi.python.org/simple/ --user Pygments
Downloading/unpacking Pygments
Downloading Pygments-2.6.1.tar.gz (3.3MB): 3.3MB downloaded
Running setup.py egg_info for package Pygments
Installing collected packages: Pygments
Running setup.py install for Pygments
SyntaxError: ('invalid syntax', ('/home/user/.local/lib/python2.7/site-packages/pygments/formatters/html.py', 554, 31, ' file=sys.stderr)\n'))
SyntaxError: ('invalid syntax', ('/home/user/.local/lib/python2.7/site-packages/pygments/lexer.py', 49, 22, 'class Lexer(metaclass=LexerMeta):\n'))
SyntaxError: ('invalid syntax', ('/home/user/.local/lib/python2.7/site-packages/pygments/style.py', 171, 22, 'class Style(metaclass=StyleMeta):\n'))
SyntaxError: ('invalid syntax', ('/home/user/.local/lib/python2.7/site-packages/pygments/cmdline.py', 161, 43, ' print("%s not found!" % what, file=sys.stderr)\n'))
Installing pygmentize script to /home/user/.local/bin
Could not find .egg-info directory in install record for Pygments
Successfully installed Pygments
Cleaning up...
And the actual error is:
$ pygmentize
Traceback (most recent call last):
File "/home/user/.local/bin/pygmentize", line 11, in <module>
load_entry_point('Pygments==2.6.1', 'console_scripts', 'pygmentize')()
File "/apps/PYTHON/2.7.3/lib/python2.7/site-packages/pkg_resources/__init__.py", line 560, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/apps/PYTHON/2.7.3/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2642, in load_entry_point
return ep.load()
File "/apps/PYTHON/2.7.3/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2296, in load
return self.resolve()
File "/apps/PYTHON/2.7.3/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2302, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/home/user/.local/lib/python2.7/site-packages/pygments/cmdline.py", line 161
print("%s not found!" % what, file=sys.stderr)
^
SyntaxError: invalid syntax
Any ideas why is this happening?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.