Verbatim / prettyprinting in mkIV
Hi all, I've been struggling with verbatim printing in MkIV for a while now and found some confusing things. I did finally get things working, but after quite some effort. I'd like to hear if my conclusions are correct, perhaps I can put them on the wiki then. I was trying to set up some custom pretty printing scripts, using lua (since I'd rather not learn complete tex scripting :-p). Looking at the files in /usr/share/texmf/tex/context/base and the wiki (Verbatim_text talks about verb-foo.tex files), I created a file called verb-foo.lua. I put this beside my document at first, and then in /usr/share/texmf/tex/context/base when it did not work, but neither worked. I tried setting things up as follows: \installprettytype [FOO] [FOO] \definetyping[FOO][option=FOO] \startFOO blub \stopFOO Trying to trace the code, I worked out things should work as follows: \installprettytype sets the "evalue" \??ty\??tyFOO to point at FOO \definetyping call \setupprettiesintypeFOO, which finds looks up the above evalue, finds FOO and then turns that into verb-foo and calls \ctxloadluafile{verb-foo}{}. This sets up the buffers.visualizers.foo value in lua. When actually starting a typing environment, dodotypeA or dodotypeD call buffers.hooks.flush_line, which in turn calls buffers.visualizers.foo.flush_line. The above didn't happen for me, so I tried manually loading the lua file using \ctxloadluafile{verb-foo}{}. After this, things started working for some reason. When looking closer and installing some \writestatus lines in core-ver.mkiv, I found that \setupprettiesintype was never actually called! Closer inspection showed that the entire core-ver.mkiv is never loaded when running "context --make". However, there is a second file, buff-ver.mkiv which closely resembles core-ver.mkiv and which is loaded. An important difference, however, is that buff-ver loads pret-foo instead of verb-foo (or rather, uses the value of \f!prettyprefix, which is set to "pret-" in mult-sys.tex). Renaming my lua file to pret-foo.lua made context find it exactly as it should, also when putting the file next to the main document. So, my main question was, are the verb-*.lua and core-ver.text files still used in any way? I just checked the minimals tree, and found out they have been removed already (but I didn't have -d in my rsync commandline to actually remove them). Looking at the previous version I was running (2009.05.20 beta) it seems that this change was actually pretty recent, so I mostly created this confusing situation by upgrading today (because my verbatim file was not properly loaded). I'm not so sure why it was not working before then, but at least it is working now. Heh, this is what you get when you write an email while you are still trying things out. All this buildup to get to a question, when the question is not even relevant. As for another relevant question: Is my analysis of how things are supposed to work correct? Then I might put something like it on the wiki. Also, it seems that \ctxloadluafile does not give an error when the file was not found. If it would have, things would probably have been a lot easier. Is there any compelling reason to make it fail silently? Gr. Matthijs
Matthijs Kooijman wrote:
Hi all,
I've been struggling with verbatim printing in MkIV for a while now and found some confusing things. I did finally get things working, but after quite some effort. I'd like to hear if my conclusions are correct, perhaps I can put them on the wiki then.
mkiv only has tex, mp and lua pretty printing and uses a different method than mkii (the mkii pretty print files are not used at all)
--make". However, there is a second file, buff-ver.mkiv which closely resembles core-ver.mkiv and which is loaded. An important difference, however, is that buff-ver loads pret-foo instead of verb-foo (or rather, uses the value of \f!prettyprefix, which is set to "pret-" in mult-sys.tex).
indeed, as part of the split (and code freeze of mkii) some core-* files have been regrouped
So, my main question was, are the verb-*.lua and core-ver.text files still used in any way?
no (it's no problem to add more mkiv pretty printers; one can take the lua one as template) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
the author of the latex 'listing' package showed some interest in porting the code to ConTeXt. Perhaps someone could contact him. Matthijs Kooijman wrote:
Hi all,
I've been struggling with verbatim printing in MkIV for a while now and found some confusing things. I did finally get things working, but after quite some effort. I'd like to hear if my conclusions are correct, perhaps I can put them on the wiki then.
I was trying to set up some custom pretty printing scripts, using lua (since I'd rather not learn complete tex scripting :-p). Looking at the files in /usr/share/texmf/tex/context/base and the wiki (Verbatim_text talks about verb-foo.tex files), I created a file called verb-foo.lua. I put this beside my document at first, and then in /usr/share/texmf/tex/context/base when it did not work, but neither worked. I tried setting things up as follows:
\installprettytype [FOO] [FOO] \definetyping[FOO][option=FOO]
\startFOO blub \stopFOO
Trying to trace the code, I worked out things should work as follows:
\installprettytype sets the "evalue" \??ty\??tyFOO to point at FOO \definetyping call \setupprettiesintypeFOO, which finds looks up the above evalue, finds FOO and then turns that into verb-foo and calls \ctxloadluafile{verb-foo}{}. This sets up the buffers.visualizers.foo value in lua. When actually starting a typing environment, dodotypeA or dodotypeD call buffers.hooks.flush_line, which in turn calls buffers.visualizers.foo.flush_line.
The above didn't happen for me, so I tried manually loading the lua file using \ctxloadluafile{verb-foo}{}. After this, things started working for some reason.
When looking closer and installing some \writestatus lines in core-ver.mkiv, I found that \setupprettiesintype was never actually called! Closer inspection showed that the entire core-ver.mkiv is never loaded when running "context --make". However, there is a second file, buff-ver.mkiv which closely resembles core-ver.mkiv and which is loaded. An important difference, however, is that buff-ver loads pret-foo instead of verb-foo (or rather, uses the value of \f!prettyprefix, which is set to "pret-" in mult-sys.tex).
Renaming my lua file to pret-foo.lua made context find it exactly as it should, also when putting the file next to the main document.
So, my main question was, are the verb-*.lua and core-ver.text files still used in any way? I just checked the minimals tree, and found out they have been removed already (but I didn't have -d in my rsync commandline to actually remove them). Looking at the previous version I was running (2009.05.20 beta) it seems that this change was actually pretty recent, so I mostly created this confusing situation by upgrading today (because my verbatim file was not properly loaded). I'm not so sure why it was not working before then, but at least it is working now.
Heh, this is what you get when you write an email while you are still trying things out. All this buildup to get to a question, when the question is not even relevant. As for another relevant question: Is my analysis of how things are supposed to work correct? Then I might put something like it on the wiki.
Also, it seems that \ctxloadluafile does not give an error when the file was not found. If it would have, things would probably have been a lot easier. Is there any compelling reason to make it fail silently?
Gr.
Matthijs
------------------------------------------------------------------------
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (3)
-
Hans Hagen
-
Matthijs Kooijman
-
Mohamed Bana