reStructuredText and Markdown have directives that generate line numbers for code snippets. Install Pygments to use these directives.
Following examples will generate this output,
1 2 |
|
reStructuredText
reStructuredText has code-block
directive to insert code snippets in your
markup. Use linenos
flag to switch on line numbers for the snippet.
.. code-block:: python
:linenos:
def example():
print 'Hello World'
Markdown
Python-Markdown uses
CodeHilite
extension for syntax highlighting. Setup
CodeHilite
, then use Shebang #!
to
generate line numbers.
#!python
def example():
print 'Hello World'