Jean-Pierre,

Thanks for this.

Jean-Pierre Chretien wrote:

[...]


4. I would like to be able to insert some Python script into a LyX file. This would require leaving
spaces in the text (whitespace is significant in Python) and using a fixed width font.



You may use any package formatting code, e.g. listing or lgrind.

Personnaly I use lgrind because it's an external program which is
prone to automated code documentation management.
If lgrind is installed on your system, you may simply test this:

lgrind -lPython foo.py foo.tex
latex foo
makeindex foo   # you get an index of the methods :-)
latex foo

and see if the layout fulfills your needs.

Then lgrind -i lPython foo.py foo.tex
will produce a file readily inserted in lyx with (in ERT)
\lgrindfile{foo}



I've found that the following gives me a tex file with functions, classes and methods listed at the side and included in the index - this looks good:


   C:\LyX\Tex\Files>lgrind -d lgrindef y.py >y.tex
   Using language python

When importing the y.tex to LyX, it appears only in LaTeXese and is not accessible for editing in the WYSIWYW mode.

The file is viewable in the dvi mode and printable from yap.

The text is displayed only in one font, so that LaTeX has added little more than the indexing.

Some questions:
1) In what directory does lgrind.exe expect to find lgrindef? Currently, I have it in the same directories as lgrind.ins,
lgrind.exe and the input text file y.py.


2) Is there some way to make the tex material available for editing in LyX?

3) Is there some way to enhance the y.tex file, see for example the attached y.html, derived from SciTE?

4) Can lgrindef be modified to permit distinctive fonts to be used for reserved words, comments, strings etc?
I don't understand LaTeXese. The attached excerpt from shows that most of the keywords are listed.


Thanks again for your help.

Any advice would be appreciated.

Colin W.
# Database of program templates for lgrind
# $Id: lgrindef,v 1.7 2000/12/27 21:42:37 mike Exp $


Python|py:\
        :pb=^\d?(def|class)\d\p(\d|\\|\(|\:):\
        :cb=#:ce=$:sb=":se=\e":lb=':le=\e':\
        :kw=accept and break class continue def del elif else except\
        exec finally for from global if import in is lambda not or\
        pass print raise return try while:

___________________________________________________________________
The following identifiers are used as reserved words, or keywords of the language, and 
cannot be used as ordinary identifiers. They must be spelled exactly as written here: 


and       del       for       is        raise    
assert    elif      from      lambda    return   
break     else      global    not       try      
class     except    if        or        while    
continue  exec      import    pass      yield    
def       finally   in        print

Note that although the identifier as can be used as part of the syntax of import 
statements, it is not currently a reserved word. 

In some future version of Python, the identifiers as and None will both become 
keywords. 

Reply via email to