Making a verbatim file for another language
I'm going to try to make a 'verbatim- module' (don't know what the right word is) for another language. I've found: /usr/local/teTeX/share/texmf.tetex/tex/context/base/verb-pl.tex and can probably have a go at making a version of this. Some questions occur: 1: where should i put my file? 2: do I have to do anything else to get Context to recognise and use it? cheers
cormullion@mac.com wrote:
I'm going to try to make a 'verbatim- module' (don't know what the right word is) for another language. I've found:
/usr/local/teTeX/share/texmf.tetex/tex/context/base/verb-pl.tex
The syntax of your intended language is indeed similar to perl? There a few definition files already there, and you should start from the one that is closest to the language you want to define (especially wrt comment and string syntax). verb-c C verb-eif Eiffel verb-js JavaScript verb-jv Java verb-mp MetaPost & MetaFont verb-pas Pascal & Modula verb-pl Perl 5 verb-sql SQL verb-tex TeX verb-xml XML
and can probably have a go at making a version of this. Some questions occur:
1: where should i put my file?
Possibly the best place is: in the context distribution, but that depends a bit on what language it is, precisely (you can email me the completed file, in that case). Second best place: http://modules.contextgarden.net, so it can be included in cont-ext.zip (third-party addons that are distributed by Pragma-Ade alongside the normal distribution). Third best: The directory <$HOME/texmf/tex/context/base> (the place where your TeX installation finds local files, I do not immediately recall the name gwTeX uses). Final option: Same directory as the file to be processed
2: do I have to do anything else to get Context to recognise and use it?
Your file has to have a name like verb-xxxx.tex, with xxxx a lowercase short identifier (example: verb-php.tex), and then you have to use one or two commands to make ConTeXt use the file. First: \installprettytype [PHP] [PHP] This maps the command \starttyping[option=PHP] to verb-php.tex. The first argument is the option as passed to \starttyping, the second argument is an uppercase version of xxxx (thus allowing context to find the file), And you probably also want: \definetyping[PHP] [option=PHP] Because that allows \startPHP ... \stopPHP as a shortcut to \setuptyping[option=PHP] Good luck, Taco
On 2006-12-25, at 10:38.0, Taco Hoekwater wrote:
cormullion@mac.com wrote:
I'm going to try to make a 'verbatim- module' (don't know what the right word is) for another language. I've found:
Good luck, Taco
Thanks - I'll need it, I think. ;-) Your very helpful reply is most appreciated. cheers
Am 2006-12-25 um 11:38 schrieb Taco Hoekwater:
There a few definition files already there, and you should start from the one that is closest to the language you want to define (especially wrt comment and string syntax). ... Good luck, Taco
I found that interesting and wikified it at http:// wiki.contextgarden.net/Verbatim_text (plus Mojca's comment to wait for LuaTeX) ;-) Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
On 12/26/06, Henning Hraban Ramm wrote:
Am 2006-12-25 um 11:38 schrieb Taco Hoekwater:
There a few definition files already there, and you should start from the one that is closest to the language you want to define (especially wrt comment and string syntax). ... Good luck, Taco
I found that interesting and wikified it at http:// wiki.contextgarden.net/Verbatim_text (plus Mojca's comment to wait for LuaTeX) ;-)
Thanks for the remark. It seems that I'm not checking the wiki pages reguraly enough to remove spam before others notice it ;) Well ... I would now rather corerct my own remark into " ... or wait a few days for Aditya's mail" ;) Mojca
After looking at these files a bit more closely, I decided I didn't have a week to spare. Too much to learn and too few instructions. For now I'm sticking with plain old black verbatim code listings. Sometimes one has to set one's sights a little lower...! :-) But thanks again.
On Tue, 26 Dec 2006, cormullion@mac.com wrote:
After looking at these files a bit more closely, I decided I didn't have a week to spare. Too much to learn and too few instructions. For now I'm sticking with plain old black verbatim code listings. Sometimes one has to set one's sights a little lower...! :-)
Is there vim syntax file for your language? Mojca and I are working on a module which uses VIM syntax highlighting to pretty print verbatim files. It is almost release quality right now. The following features are working. You can define \defineVIMtyping [MATLAB] [syntax=matlab] and then use \startMATLAB .... \stopMATLAB where the result is pretty printed. A whole file can be printed using \definetypeVIMfile [typeMATLAB] [syntax=matlab] \typeMATLAB[file.m] You can select the lines of the file to print, though there is no support for showing linenumbers yet. The script is slooow, and the delay is noticable for anything close to 1000 lines. But a few 100 lines should work just fine. If you have vim and are interested in testing, you can be the first tester of the module :) Aditya
On Thu, 28 Dec 2006, cormullion@mac.com wrote:
On 2006-12-27, at 21:41.0, Aditya Mahajan wrote:
If you have vim and are interested in testing, you can be the first tester of the module :)
Hi! Yes I can find a vim module, so if you can tell me which files to put where, I'll give it a try!
I have attached the files. Please note that we are still playing around with the module, so certain features will change. Right now, place t-vimsyntax.tex and 2context.vim files in the working directory. You need to have write18 enabled. Add \usemodule[vimsyntax] on the top of your file. (And ofcourse, \setupcolors[state=start]) 1. If you want to typeset an existing file, and lets say the filetype (in vim's terms) is ruby. Then \definetypeVIMfile [name of macro] %Usually typeRUBY, typeMATLAB, etc. [ % Optional arguments start=<linenumber>, %starting line number, defaults to 1 stop=linenumber, %stopping line number, defaults to 0, %and 2context makes it end of file tab=<tabstop>, %How many spaces should a tab mean, %defaults to 8. %Support for visible tab will be added. space=(yes|on|no) %no ignores spaces, yes honors file spaces %on makes spaces visible. vimcolorscheme=<colorscheme>, %Which vim colorscheme to use %defaults to pscolor, which is the only %scheme implemented so far. syntax=<syntax>, %Which syntax highlighing to use in vim. ] % End of optional arguments In the simplest case, you will have \definetypeVIMfile [typeRUBY] [syntax=ruby] % tab and spaces to your preference Then you can use \typeRUBY [optional arguments, as above] {filename} %filename needs extension also 2. If you need to type code snippets \defineVIMtyping [RUBY] [syntax=ruby] %Other options same as above and then \startRUBY # This is a ruby program puts "Hello World" \stopRUBY Let us know if you come across any problems. Aditya
On 12/28/06, cormullion@mac.com wrote:
How does it find the .vim language syntax file for - say - Ruby?
When you start vim and say "set syntax=ruby", vim should find the syntax file automatically. For example under: /usr/share/vim/vimXX/syntax/ruby.vim c:/programs/vim/vimXX/syntax/ruby.vim depending on your vim runtime environment. :help VIMRUNTIME Mojca
OK, I think vim works OK here, so this is what I tried: ... \setupcolors[state=start] \usemodule[vimsyntax] \definetypeVIMfile [typeRUBY] [syntax=ruby] \typeRUBY[typeRUBY]{fibo.rb} \defineVIMtyping[RUBY][syntax=ruby] \startRUBY # This is a ruby program puts "Hello World" \stopRUBY ... Error message was this: system : no macros found in module vimsyntax ! Undefined control sequence. l.15 \definetypeVIMfile [typeRUBY] [syntax=ruby] So it looks like it didn't really get started... The files t- vimsyntax.text and 2context.vim are rattling loose in the directory...
On 12/29/06, cormullion@mac.com wrote:
OK, I think vim works OK here, so this is what I tried:
... \setupcolors[state=start]
\usemodule[vimsyntax]
\definetypeVIMfile [typeRUBY] [syntax=ruby]
\typeRUBY[typeRUBY]{fibo.rb}
\defineVIMtyping[RUBY][syntax=ruby]
\startRUBY # This is a ruby program
puts "Hello World" \stopRUBY ...
Error message was this:
system : no macros found in module vimsyntax
Weird! Do you have a file t-vimsyntax.tex in the same folder as the file where you're running the sample? An alternative is to place the file under [texmf]/tex/context/third/t-vimsyntax.tex and then run "[sudo] mktexlsr". But in any case you need to have 2context.vim in the same folder (there is no support for an arbitrary path of the script yet).
! Undefined control sequence. l.15 \definetypeVIMfile [typeRUBY] [syntax=ruby]
So it looks like it didn't really get started... The files t- vimsyntax.text and 2context.vim are rattling loose in the directory...
It has to be *t-vimsyntax.tex*, not *.text*, if that's the case. But if I try to rename the file, I get "module vimsyntax not found", while you get "no macros found in module vimsyntax". While googling through the archive I've found the following message: http://archive.contextgarden.net/message/20050215.182506.0838140e.en.html Citing:
tracefiles showed that ConTeXt was expecting a file name with six or less characters after t-; my module was called t-utfgreek, so ConTeXt was looking for t-utfgre and couldn't find it
Which version of TeX/ConTeXt are you using? (Perhaps Hans has changed something in the meantime, to make that work again.) Are you using Gerben's i-Installer? In that case and if you have a chance, can you please test the new TeXLive-based distribution? (I didn't know that 8-char was still a limitation nowadays.) Mojca
On Fri, 29 Dec 2006, Mojca Miklavec wrote:
On 12/29/06, cormullion@mac.com wrote:
OK, I think vim works OK here, so this is what I tried:
... \setupcolors[state=start]
\usemodule[vimsyntax]
\definetypeVIMfile [typeRUBY] [syntax=ruby]
\typeRUBY[typeRUBY]{fibo.rb}
\defineVIMtyping[RUBY][syntax=ruby]
\startRUBY # This is a ruby program
puts "Hello World" \stopRUBY ...
Error message was this:
system : no macros found in module vimsyntax
Weird! Do you have a file t-vimsyntax.tex in the same folder as the file where you're running the sample? An alternative is to place the file under [texmf]/tex/context/third/t-vimsyntax.tex and then run "[sudo] mktexlsr".
But in any case you need to have 2context.vim in the same folder (there is no support for an arbitrary path of the script yet).
! Undefined control sequence. l.15 \definetypeVIMfile [typeRUBY] [syntax=ruby]
So it looks like it didn't really get started... The files t- vimsyntax.text and 2context.vim are rattling loose in the directory...
It has to be *t-vimsyntax.tex*, not *.text*, if that's the case. But if I try to rename the file, I get "module vimsyntax not found", while you get "no macros found in module vimsyntax".
While googling through the archive I've found the following message: http://archive.contextgarden.net/message/20050215.182506.0838140e.en.html
Citing:
tracefiles showed that ConTeXt was expecting a file name with six or less characters after t-; my module was called t-utfgreek, so ConTeXt was looking for t-utfgre and couldn't find it
You can also try renaming t-vimsyntax.tex to t-vims.tex and then using \usemodule[vims] But with an old ConTeXt, there can be other things that do not work. The best thing will be to update.
Which version of TeX/ConTeXt are you using? (Perhaps Hans has changed something in the meantime, to make that work again.) Are you using Gerben's i-Installer? In that case and if you have a chance, can you please test the new TeXLive-based distribution?
(I didn't know that 8-char was still a limitation nowadays.)
AFAIK, it is not. The 8-char limitation was removed about two years ago. Aditya
On 2006-12-29, at 13:09.0, Mojca Miklavec wrote:
Which version of TeX/ConTeXt are you using? (Perhaps Hans has changed something in the meantime, to make that work again.) Are you using Gerben's i-Installer? In that case and if you have a chance, can you please test the new TeXLive-based distribution?
---- TeXExec 5.2.4 - ConTeXt / PRAGMA ADE 1997-2005 executable : pdfetex format : cont-en inputfile : test2 output : pdftex interface : en current mode : none TeX run : 1 This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5) \write18 enabled. (/usr/local/teTeX/share/texmf.tetex/web2c/natural.tcx) ---- yes - and it's a default Gerben i-Installation, installed 1 week ago. I wouldn't really know how to do any other kind... ;-) I was hoping to use ConTeXt like I would use a luxury Mercedes car, to go places without having to open the engine door at all - but perhaps I will have to peer underneath the lid occasionally. :-) But - if it looks like I have to spend much time in the garage underneath the car, perhaps I will try to work out how you are calling external programs during the compilation of the document... I didn't know you could do that, and it might be a great avenue for exploration (once I have my overalls on)...! thanks!
On Fri, 29 Dec 2006, cormullion@mac.com wrote:
On 2006-12-29, at 13:09.0, Mojca Miklavec wrote:
Which version of TeX/ConTeXt are you using? (Perhaps Hans has changed something in the meantime, to make that work again.) Are you using Gerben's i-Installer? In that case and if you have a chance, can you please test the new TeXLive-based distribution?
---- TeXExec 5.2.4 - ConTeXt / PRAGMA ADE 1997-2005
executable : pdfetex format : cont-en inputfile : test2 output : pdftex interface : en current mode : none TeX run : 1
This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5) \write18 enabled. (/usr/local/teTeX/share/texmf.tetex/web2c/natural.tcx) ---- This is the perl version of texexec
yes - and it's a default Gerben i-Installation, installed 1 week ago. I wouldn't really know how to do any other kind... ;-)
try using texmfstart texexec filename which should call the ruby version of texexec. What is the output of texmfstart texexec --check It will take some time, and it will be a long output, just post the first 10-15 lines. Aditya
On 2006-12-29, at 15:59.0, Aditya Mahajan wrote:
This is the perl version of texexec
I do everything from TeXShop (http://www.uoregon.edu/~koch/texshop) and BBEdit so I have no idea where anything TeX-y is... I spent half an hour finding out how to 'enable write 18'... ;-) Poking around inside this stuff is probably too much, too soon for me, since I'm a newcomer to the whole thing... In that sense I'm probably not the best tester for this stuff. :-)
On 12/29/06, cormullion@mac.com wrote:
On 2006-12-29, at 13:09.0, Mojca Miklavec wrote:
Which version of TeX/ConTeXt are you using? (Perhaps Hans has changed something in the meantime, to make that work again.) Are you using Gerben's i-Installer? In that case and if you have a chance, can you please test the new TeXLive-based distribution?
---- TeXExec 5.2.4 - ConTeXt / PRAGMA ADE 1997-2005
executable : pdfetex format : cont-en inputfile : test2 output : pdftex interface : en current mode : none TeX run : 1
This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5) \write18 enabled. (/usr/local/teTeX/share/texmf.tetex/web2c/natural.tcx) ----
yes - and it's a default Gerben i-Installation, installed 1 week ago. I wouldn't really know how to do any other kind... ;-)
Hmmm ... Gerben's i-Installer has switched from tetex to TeX Live (very) recently (TeX Live hasn't even been released yet). I would suggest you to try to install "TeX Live" if possible. If anything goes wrong, he'll only answer mails until 1.1.2007. I have no idea whether anyone from the ConTeXt community has tested that already. And I have no idea what will happen with the installer in the future ... (Just for an explanation: you can choose whether to install tetex or TeX Live, you have to choose the new TeX Live. You probably have to install from scratch.) With TeX Live-based sources texmfstart should work by default, so it will mean less problems in the future. Mojca
Aditya Mahajan kirjoitti 28.12.2006 kello 19.09: [About ConTeXt and Vim module for syntax highlighting.]
Let us know if you come across any problems.
Works fine here. System: Mac OS 10.4.8, using default Vim (6.2: yikes, thats old!). ConTeXt ver: 2006.08.08 21:51 fmt: 2006.11.1 -- Jarimatti Valkonen javalkon@hytti.uku.fi
On 2006-12-30, at 09:22.0, Jarimatti Valkonen wrote:
Aditya Mahajan kirjoitti 28.12.2006 kello 19.09:
[About ConTeXt and Vim module for syntax highlighting.]
Let us know if you come across any problems.
Works fine here. System: Mac OS 10.4.8, using default Vim (6.2: yikes, thats old!). ConTeXt ver: 2006.08.08 21:51 fmt: 2006.11.1
Thanks Jarimatti for sharing that. It suggests that my week-old installation isn't the most up to date one:
ConTeXt ver: 2005.01.31 fmt: 2006.7.23 int: english mes: english
I obviously chose a suboptimal option when I started i-Installer. (Not difficult, really - it felt like a first attempt to hot-wire a Boing 747... :-) I'm reluctant to re-install the whole thing, when ConTeXt is currently working so well. Perhaps next week.
cormullion@mac.com kirjoitti 30.12.2006 kello 16.18:
On 2006-12-30, at 09:22.0, Jarimatti Valkonen wrote:
Works fine here. System: Mac OS 10.4.8, using default Vim (6.2: yikes, thats old!). ConTeXt ver: 2006.08.08 21:51 fmt: 2006.11.1
Thanks Jarimatti for sharing that. It suggests that my week-old installation isn't the most up to date one:
ConTeXt ver: 2005.01.31 fmt: 2006.7.23 int: english mes: english
I obviously chose a suboptimal option when I started i-Installer. (Not difficult, really - it felt like a first attempt to hot-wire a Boing 747... :-)
That is odd, as I haven't updated my ConTeXt in a while. My ConTeXt updater i-Package (context-update.ii2) is dated 2006/10/06 meaning that it's almost three months old. And I'm still using the teTeX installation that is apparently no longer available (tex.ii2). Anyway, I use ConTeXt from the shell (Terminal.app) and have defined the following aliases: --- # ConTeXt stuff alias texmfstart="ruby /usr/local/teTeX/share/texmf.local/scripts/ context/ruby/texmfstart.rb" alias context="texmfstart texexec" --- You could try those, just change the name and path to texmfstart.rb so that it matches your installation. After adding the aliases you can just issue command 'context myfile.tex' and the file gets processed. -- Jarimatti Valkonen javalkon@hytti.uku.fi
On 2006-12-30, at 21:24.0, Jarimatti Valkonen wrote:
/usr/local/teTeX/share/texmf.local/scripts/context/ruby/texmfstart.rb
Unfortunately, I don't have a scripts directory here... Obviously my system is not correctly installed. What is the recommended way to install the latest Context version (MacOS X)?
On 12/31/06, cormullion@mac.com wrote:
What is the recommended way to install the latest Context version (MacOS X)?
You have to install at least the following two packages: - gwTeX based on TeX Live (texlive.ii2) - gwTeX Support: ConTeXt updater (context-update.ii2) Perhaps uninstall both ConTeXt and "DEPRECATED" gwTeX based on teTeX and TeX Live first (tex.ii2) before installing texlive.ii2 and install context-update at the end again. You also have to configure auto-updating, but I'm not sure how to do that properly. Mojca
On 2006-12-31, at 13:40.0, Mojca Miklavec wrote:
On 12/31/06, cormullion@mac.com wrote:
What is the recommended way to install the latest Context version (MacOS X)?
You have to install at least the following two packages: - gwTeX based on TeX Live (texlive.ii2) - gwTeX Support: ConTeXt updater (context-update.ii2)
Good news - I deleted everything from my system and re-installed from scratch. Now everything works better - and I've even got the vimsyntax coloring up my Lisp code! Cool. Thanks very much for your help...
On 12/25/06, cormullion@mac.com wrote:
I'm going to try to make a 'verbatim- module' (don't know what the right word is) for another language. I've found:
/usr/local/teTeX/share/texmf.tetex/tex/context/base/verb-pl.tex
and can probably have a go at making a version of this. Some questions occur:
1: where should i put my file? 2: do I have to do anything else to get Context to recognise and use it?
cheers
Unless you need that highlighting urgently, I would wait for luatex in your case and write it in lua then (which is certainly less painful than writing it in plain TeX). But it's up to you. I found those TeX definitions too complicated to even try to understand, I would never dare to try writing one by myself. Mojca
On Mon, 25 Dec 2006, Mojca Miklavec wrote:
On 12/25/06, cormullion@mac.com wrote:
I'm going to try to make a 'verbatim- module' (don't know what the right word is) for another language. I've found:
/usr/local/teTeX/share/texmf.tetex/tex/context/base/verb-pl.tex
and can probably have a go at making a version of this. Some questions occur:
1: where should i put my file? 2: do I have to do anything else to get Context to recognise and use it?
cheers
Unless you need that highlighting urgently, I would wait for luatex in your case and write it in lua then (which is certainly less painful than writing it in plain TeX). But it's up to you. I found those TeX definitions too complicated to even try to understand, I would never dare to try writing one by myself.
Any update on 2context.vim? Then things could be as simple as \startVIMtyping[ft=mylang,colorscheme=fancy] Your code \stopVIMtyping with a external call to vim -u NONE buffer.tmp with an appropriate autocommand to set filetype, colorscheme and source 2context. Aditya
participants (6)
-
Aditya Mahajan
-
cormullion@mac.com
-
Henning Hraban Ramm
-
Jarimatti Valkonen
-
Mojca Miklavec
-
Taco Hoekwater