Hello (sorry for my bad english)
I use textmate with the theme Eiffel to create my latex code.
When i want to put this code on my site, i use two commands of the TextMate's Bundle :
Create HTML From Document and Create CSS From Current Theme
This works very fine : http://altermundus.fr/pages/lx/tb.html
But :
The css is very heavy and the source code also and it's very difficult to modify this code
The same code is at this page on the site of Kjell Magne Fauskes
http://www.fauskes.net/pgftikzexamples/ (clic on the Sign diagram)
Kjell uses pygments a module of Python. The css and the code are more simple and the result is correct
Two questions :
1) is it possible (perhaps with a better theme create only for latex) to get a css more simple and a lighter source ?
2) is it possible to use pygments ( http://sourceforge.net/projects/ pygments/ or http://pygments.pocoo.org/ ) from TextMate with Python's Bundle
Greetings Alain
ps : The result of the css with textmate is very fine but is difficult to modify it directly by hand !
On Feb 3, 2007, at 9:46 AM, Alain Matthes wrote:
Hello (sorry for my bad english) The same code is at this page on the site of Kjell Magne Fauskes
http://www.fauskes.net/pgftikzexamples/ (clic on the Sign diagram)
Kjell uses pygments a module of Python. The css and the code are more simple and the result is correct
Two questions :
- is it possible (perhaps with a better theme create only for
latex) to get a css more simple and a lighter source ?
Not via the current system, I don't think. The source contains all the information that the parser has, and ASAIK there is no easy way to tell it to ignore some of them (other than writing some custom search-and-replace script that removes the extra stuff you don't want)
- is it possible to use pygments ( http://sourceforge.net/projects/
pygments/ or http://pygments.pocoo.org/ ) from TextMate with Python's Bundle
It would perhaps be possible, the Python bundle wouldn't enter into it at all. But looking at the links you posted, pygments doesn't seem to support LaTeX as one of the languages for input. So we'll need to know a bit more about what Kjell is doing, in order to be able to help.
Greetings Alain
ps : The result of the css with textmate is very fine but is difficult to modify it directly by hand !
Haris
Le 3 févr. 07 à 16:54, Charilaos Skiadas a écrit :
It would perhaps be possible, the Python bundle wouldn't enter into it at all. But looking at the links you posted, pygments doesn't seem to support LaTeX as one of the languages for input. So we'll need to know a bit more about what Kjell is doing, in order to be able to help.
pygments can take a latex file
I 'm not an expert with python : it's my first code !
import codecs from pygments import highlight from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter>>> from pygments.formatters import HtmlFormatter from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter fileObj = codecs.open("/Users/ego/Desktop/sign-diagram.tex", "r" , "utf8") code = fileObj.read() filecontent = highlight(u, TexLexer(), HtmlFormatter()) unicodefilecontent = unicode(filecontent) out = file( "/Users/ego/Desktop/sign-diagram.html", "w") out.write(unicodefilecontent) out.close()
and with
print HtmlFormatter().get_style_defs('.highlight') i've the css
Alain
ps Kjell do'nt work with Textmate but Kjell use python and Django for his site !
Le 4 févr. 07 à 17:45, Alain Matthes a écrit :
I 'm not an expert with python : it's my first code !
ans i make a mistake with cut and paste
import codecs from pygments import highlight from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter fileObj = codecs.open("/Users/ego/Desktop/sign-diagram.tex", "r" , "utf8") code = fileObj.read() filecontent = highlight(u, TexLexer(), HtmlFormatter()) unicodefilecontent = unicode(filecontent) out = file( "/Users/ego/Desktop/sign-diagram.html", "w") out.write(unicodefilecontent) out.close()
it's better like this
Alain
ps perhaps an expert with python can help me with : import os, sys etc... to make this script more easy to use !
Ok, so I can generate something nice with a code like this (warning, not a python coder):
import codecs from pygments import highlight from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter fileObj = codecs.open("/Users/haris/Desktop/sign-diagram.tex", "r" , "utf8") code = fileObj.read() filecontent = highlight(code, TexLexer(), HtmlFormatter()) unicodefilecontent = unicode(filecontent) out = file( "/Users/haris/Desktop/sign-diagram.html", "w") out.write("<html><head><style>") out.write(HtmlFormatter().get_style_defs('.highlight')) out.write("</style></head><body>") out.write(unicodefilecontent) out.write("</body></html>") out.close()
Now, I assume you want to create some TextMate command that does something nice with it? What exactly would you want? I think we can probably accomplish it.
Haris
Le 4 févr. 07 à 19:37, Charilaos Skiadas a écrit :
Now, I assume you want to create some TextMate command that does something nice with it? What exactly would you want? I think we can probably accomplish it.
Thanks Haris
Something like the texmate bundle command
Create a html file form a latex file and Create a css file
with Pygments
the problem is to use the good directory "/Users/haris/Desktop/sign- diagram.tex" we must use a variable directory !
the tex file is on a project (tex) and i think the best is to apply the new command on the file inside the tex project.
Alain
On Feb 4, 2007, at 2:47 PM, Alain Matthes wrote:
thydere
??? sorry but i don't understand...
Not much to understand, that's the IRC name of the guy who helped me fix this.
Traceback (most recent call last): File "/tmp/temp_textmate.tERir7", line 4, in ? from pygments import highlight ImportError: No module named pygments
Looks like you don't have pygments installed, it doesn't come built in. You would need to install pygments first, or wait a bit until (if) we package it with TextMate.
Haris
Le 4 févr. 07 à 21:29, Charilaos Skiadas a écrit :
On Feb 4, 2007, at 2:47 PM, Alain Matthes wrote:
thydere
??? sorry but i don't understand...
Not much to understand, that's the IRC name of the guy who helped me fix this.
Traceback (most recent call last): File "/tmp/temp_textmate.tERir7", line 4, in ? from pygments import highlight ImportError: No module named pygments
Looks like you don't have pygments installed, it doesn't come built in. You would need to install pygments first, or wait a bit until (if) we package it with TextMate.
Pygments is install this code work :
import codecs from pygments import highlight from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter>>> from pygments.formatters import HtmlFormatter from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter fileObj = codecs.open("/Users/ego/Desktop/sign-diagram.tex", "r" , "utf8") code = fileObj.read() filecontent = highlight(u, TexLexer(), HtmlFormatter()) unicodefilecontent = unicode(filecontent) out = file( "/Users/ego/Desktop/sign-diagram.html", "w") out.write(unicodefilecontent) out.close()
when i run python !
Alain
Alain,
You need to set up your path. See my previous email.
- Alex
On Feb 4, 2007, at 12:50 PM, Alain Matthes wrote:
Le 4 févr. 07 à 21:29, Charilaos Skiadas a écrit :
On Feb 4, 2007, at 2:47 PM, Alain Matthes wrote:
thydere
??? sorry but i don't understand...
Not much to understand, that's the IRC name of the guy who helped me fix this.
Traceback (most recent call last): File "/tmp/temp_textmate.tERir7", line 4, in ? from pygments import highlight ImportError: No module named pygments
Looks like you don't have pygments installed, it doesn't come built in. You would need to install pygments first, or wait a bit until (if) we package it with TextMate.
Pygments is install this code work :
import codecs from pygments import highlight from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter>>> from pygments.formatters import HtmlFormatter from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter fileObj = codecs.open("/Users/ego/Desktop/sign-diagram.tex", "r" , "utf8") code = fileObj.read() filecontent = highlight(u, TexLexer(), HtmlFormatter()) unicodefilecontent = unicode(filecontent) out = file( "/Users/ego/Desktop/sign-diagram.html", "w") out.write(unicodefilecontent) out.close()
when i run python !
Alain ______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Feb 4, 2007, at 3:57 PM, Alexander Ross wrote:
Alain,
You need to set up your path. See my previous email.
- Alex
Pygments is install this code work :
import codecs from pygments import highlight from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter>>> from pygments.formatters import HtmlFormatter from pygments.lexers import TexLexer from pygments.formatters import HtmlFormatter fileObj = codecs.open("/Users/ego/Desktop/sign-diagram.tex", "r" , "utf8") code = fileObj.read() filecontent = highlight(u, TexLexer(), HtmlFormatter()) unicodefilecontent = unicode(filecontent) out = file( "/Users/ego/Desktop/sign-diagram.html", "w") out.write(unicodefilecontent) out.close()
when i run python !
As Alex said, you need to work a bit with your path settings because you have two pythons installed, and only one of them has Pygments. And it is not the one that your computer can find without the .bash_profile file. Or change the first line in the script to point directly to the correct python executable. So probably something like:
#!/Library/Frameworks/Python.framework/Versions/Current/bin/python
instead of the current:
#!/usr/bin/env python
And also, the above code does not run properly in fact even if you have Pygments, because the "u" in the filecontent=... line should have been a "code" ;).
Alain
Haris
Le 4 févr. 07 à 20:33, Charilaos Skiadas a écrit :
On Feb 4, 2007, at 2:28 PM, Charilaos Skiadas wrote:
The attached commands work with the current document.
A more unicode-safe Convert, thanks to thydere.
I've an error :
Traceback (most recent call last): File "/tmp/temp_textmate.tERir7", line 4, in ? from pygments import highlight ImportError: No module named pygments
perhaps it's my installation :
The version of python is 2.5 and it is here :
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
Alain
Le 4 févr. 07 à 21:12, Alain Matthes a écrit :
and in my .bash_profile i 've :
# Setting PATH for MacPython 2.5 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}" export PATH
Alain
Alain,
For commands written in python, your .bash_profile doesn't get sourced. You can either set up a ~/.MacOSX/environment.plist[1], or you can just edit the #! of the tm_command to point to your installation of python. The first solution is probably wiser, as it will apply for all of your other commands too.
- Alex
[1]: http://macromates.com/textmate/manual/shell_commands On Feb 4, 2007, at 12:15 PM, Alain Matthes wrote:
Le 4 févr. 07 à 21:12, Alain Matthes a écrit :
and in my .bash_profile i 've :
# Setting PATH for MacPython 2.5 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$ {PATH}" export PATH
Alain ______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Le 4 févr. 07 à 21:29, Alexander Ross a écrit :
Alain,
For commands written in python, your .bash_profile doesn't get sourced. You can either set up a ~/.MacOSX/environment.plist[1], or you can just edit the #! of the tm_command to point to your installation of python. The first solution is probably wiser, as it will apply for all of your other commands too.
- Alex
Yes i understand that, but the installation of python is strange and it's my problem no it's solved
The alias of python in /usr/bin/ was for python2.3 and not python2.5; that's why i make a first mistake with a bad path export in my bash_profile.
Now all is fine
Thanks to every one
Alain
Alain,
I'm glad that's sorted out. :)
- Alex
On Feb 4, 2007, at 1:05 PM, Alain Matthes wrote:
Le 4 févr. 07 à 21:29, Alexander Ross a écrit :
Alain,
For commands written in python, your .bash_profile doesn't get sourced. You can either set up a ~/.MacOSX/environment.plist[1], or you can just edit the #! of the tm_command to point to your installation of python. The first solution is probably wiser, as it will apply for all of your other commands too.
- Alex
Yes i understand that, but the installation of python is strange and it's my problem no it's solved
The alias of python in /usr/bin/ was for python2.3 and not python2.5; that's why i make a first mistake with a bad path export in my bash_profile.
Now all is fine
Thanks to every one
Alain
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
I you have pygments installed via python 2.5 you have to put the path into ~/.MacOSX/environment.plist since the .bash_profile will only be read by a terminal (which means that TextMate is using python 2.3 at the moment where you obviously haven't installed pygments). To solve this problem you have three options:
1. create ~/.MacOSX$ cat environment.plist (if it doesn't already exist) and insert something like { PATH = '~/bin:/usr/local/bin:...';} 2. install pygments in python 2.3 3. load pygments (either the egg which you have to unzip afterwards or the source), put the pygments directory into ~/Library/Application \ Support/TextMate/Support/lib, and add the following lines between line 4 and 5 of Haris's command:
import os import sys sys.path.append('%s/lib' % os.environ['TM_SUPPORT_PATH'])
greetings Wolfgang
On 04.02.2007, at 21:15, Alain Matthes wrote:
Le 4 févr. 07 à 21:12, Alain Matthes a écrit :
and in my .bash_profile i 've :
# Setting PATH for MacPython 2.5 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$ {PATH}" export PATH
Alain ______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Le 4 févr. 07 à 22:15, Wolfgang Machert a écrit :
I you have pygments installed via python 2.5 you have to put the path into ~/.MacOSX/environment.plist since the .bash_profile will only be read by a terminal (which means that TextMate is using python 2.3 at the moment where you obviously haven't installed pygments).
the problem is solved
Explication :
When I installed Pyton2.5, all the files of python2.3 was reased but the links in /usr/bin remained to direct towards Python2.3, on the other hand a link was created in /usr/local/bin towards python 2.5
And i think, it is initially in /usr/bin that the file is required
Now i ve only python 2.5 in my mac and a good link in /usr/bin/
To solve this problem you have three options:
- create ~/.MacOSX$ cat environment.plist (if it doesn't already
exist) and insert something like { PATH = '~/bin:/usr/local/bin:...';}
Now i think that ~/.MacOSX/environment.plist is not useful ? perhaps i'm wrong ...
in my profile i've
PATH="/bin:/sbin:/usr/bin:/usr/sbin" export PATH
if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi if [ `whoami` != "root" ] then PATH="$PATH:/usr/texbin" export PATH fi if [ `whoami` != "root" ] then PATH="$PATH:/usr/local/bin" export PATH fi
and /usr/bin is used before /usr/local/bin with the bad link in the first !
Greetings Alain
Alain,
To solve this problem you have three options:
- create ~/.MacOSX$ cat environment.plist (if it doesn't already
exist) and insert something like { PATH = '~/bin:/usr/local/ bin:...';}
Now i think that ~/.MacOSX/environment.plist is not useful ? perhaps i'm wrong ...
It is actually very useful: the environment.plist is for the OS adequate to the .profile for your terminal. All programs trying to open a shell (to execute commandos) will use settings in that file as environment. Since I use python scripts in more apps than Terminal and TextMate I chose that way to have my PATH (and LC_TYPE for that) propagated.
in my profile i've [...] and /usr/bin is used before /usr/local/bin with the bad link in the first !
Well if this is working for you - so be it. There is no right or wrong, it just might happen that you have to modify some more pointer once you installed more external software. The normal UNIX schema would be to put generic programs into /usr/bin and (machine) specific programs into /usr/local/bin - so the later path would normally be loaded before the former. Most of the install packages honor these schematics and put stuff into /usr/local/...
However the final step is a matter of preference. If what you did is working for you, it's fine. Just keep in mind that there are actually different possible solutions when you have access to a different machine (or have to deploy you work).
greetings Wolfgang
Le 4 févr. 07 à 23:53, Wolfgang Machert a écrit :
However the final step is a matter of preference. If what you did is working for you, it's fine. Just keep in mind that there are actually different possible solutions when you have access to a different machine (or have to deploy you work).
Thanks Wolgang i just keep that in mind. Actually, there is no problem for me to create this file and to see the result.. But i want to understand very well the mechanism
An i agree with you that perhaps with ruby, i need this different solution.
I'm not very sure when i try to work like a unix geek, and some files are very strange : profile .profile .profile_bash .bachrc and now ~/.MacOSX/environment.plist. it's a lot of stuff around the same idea ( set a good path) and the solution on the net are often different.
Thanks for you explanation !
Grreetings Alain
Here's also a generic command using pygments to do generate HTML using the current bundle mode as language, falling back to plain text if no lexer could be found. In case someone is looking for that :).
Wolfgang
On 04.02.2007, at 20:33, Charilaos Skiadas wrote:
On Feb 4, 2007, at 2:28 PM, Charilaos Skiadas wrote:
The attached commands work with the current document.
A more unicode-safe Convert, thanks to thydere.
Alain
Haris
Haris