[NTG-context] processing xml with lua
Hi all, one of my favorite topics… Here is a minimal example which shows something that I don't understand: when I process the subsection with the lua code, I want to get the value of the current section's label attribute in xml.attribute(r, ../../section, label, X). So i was expecting that lua would go up (../../) and fetch the current section's label. But if you run the example, you see that it actually always gets the first section's label (value is always 1). How can I get the current section's label with a lua function? THanks and all best Thomas \startbuffer[test] chapter section label=1 subsection label=1 content text 1.1 /content /subsection /section section label=3 subsection label=1 content text 3.1 /content /subsection subsection label=5 content text 3.5 /content /subsection /section /chapter \stopbuffer \startxmlsetups xml:testsetups \xmlsetsetup{\xmldocument}{chapter|section|subsection|content}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups xml:chapter \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:section \xmlflush{#1} \par \stopxmlsetups \startxmlsetups xml:subsection \xmlfunction{#1}{test} \stopxmlsetups \startluacode outfile = io.open('temp.tmp', 'w') function xml.functions.test(r) content = xml.text(r, content) section = xml.attribute(r, ../../section, label, X) context(This ) context(content) context( is in section ) context(section) end \stopluacode \starttext \xmlprocessbuffer{main}{test}{} \enabletrackers[context.trace] \xmlshow{main} \stoptext ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] processing xml with lua
On 2/26/2013 1:23 PM, Schmitz Thomas A. wrote: Hi all, one of my favorite topics… Here is a minimal example which shows something that I don't understand: when I process the subsection with the lua code, I want to get the value of the current section's label attribute in xml.attribute(r, ../../section, label, X). So i was expecting that lua would go up (../../) and fetch the current section's label. But if you run the example, you see that it actually always gets the first section's label (value is always 1). How can I get the current section's label with a lua function? you go up to the parent of sections which to far up, try: section = xml.attribute(r, .., label, X) or section = xml.filter(r, ../attribute(label)) THanks and all best Thomas \startbuffer[test] chapter section label=1 subsection label=1 content text 1.1 /content /subsection /section section label=3 subsection label=1 content text 3.1 /content /subsection subsection label=5 content text 3.5 /content /subsection /section /chapter \stopbuffer \startxmlsetups xml:testsetups \xmlsetsetup{\xmldocument}{chapter|section|subsection|content}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups xml:chapter \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:section \xmlflush{#1} \par \stopxmlsetups \startxmlsetups xml:subsection \xmlfunction{#1}{test} \stopxmlsetups \startluacode outfile = io.open('temp.tmp', 'w') function xml.functions.test(r) content = xml.text(r, content) section = xml.attribute(r, ../../section, label, X) context(This ) context(content) context( is in section ) context(section) end \stopluacode \starttext \xmlprocessbuffer{main}{test}{} \enabletrackers[context.trace] \xmlshow{main} \stoptext ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] processing xml with lua
On Feb 26, 2013, at 1:54 PM, Hans Hagen pra...@wxs.nl wrote: you go up to the parent of sections which to far up, try: section = xml.attribute(r, .., label, X) or section = xml.filter(r, ../attribute(label)) Mojca, Hans, thanks, that is exactly right! I wasn't too sure about ../../section, but now it makes sense. I have to study xpath a bit more, I guess. All best Thomas ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] default parameter in \definefont
On Tue, 26 Feb 2013 08:18:25 +0100 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Am 26.02.2013 um 00:00 schrieb john Culleton j...@wexfordpress.com: Some time back Wolfgang advised me to use statements like this: \definefont [titlefont][MyriadPro-Bold*default at 70bp] I cannot find what the *default parameter does. Can someone educate me? When you use a font in MkIV you have to specify which features of the font should be enabled/disabled, to do this you define first a list for them with the \definefontfeature command, e.g. \definefontfeature[myfeatures][liga=yes,onum=yes,___] For the main fonts in the document which are loaded with \setupbodyfont these settings are applied in the typescripts, e.g. \defintfontsynonym[Serif][MyRegularFont][features=myfeatures] but when you load a single font with \definefont you apply the list as argument to the font name after the asterisk. When you want only a bigger version of the serif or sans version of your document you can say \definefont[SansBold at 70bp] without applying the list of features because the are already set in the typescripts. Wolfgang Is there a document or documents whare all this knowledge is dispensed? I hesitate to trouble you with a string of questions, one by one. Right now the two critical files are: \input formatting.tex --- \usemodule [simplefonts] \definefont [titlefont][MyriadPro-Bold*default at 70bp] \definefont [subtitle][MyriadPro-Bold*default at 25bp] \definefont [gauthor][MinionPro-Regular*default at 25bp] --- followed by: \input title.tex - \startstandardmakeup[align=middle] \startstyle[titlefont] Classic COBOL \stopstyle \vfil \style[subtitle]{A Concise Guide} \vfil \null \vfil \style[gauthor]{John Culleton} \vfil \style[subtitle]{Wexford Press} \stopstandardmakeup And the error messages indicate that MKIV cannot find those otf files but they exist in /usr/share/fonts/OTF. The run completes but other fonts and sizes are used for the title page. -- John Culleton Wexford Press ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] recalculate background on every page with \uniqueMPgraphic?
On Mon, Feb 18, 2013 at 10:53 AM, Marco Patzer home...@lavabit.com wrote: On 2013–02–18 Mikael P. Sundqvist wrote: Thank you Marco for giving a better example. I thought that uniqueMPgraphic meant it was redrawn everytime while useMPgraphic meant it was done once and then gave the same result everytime used. http://thread.gmane.org/gmane.comp.tex.context/79507/focus=79538 In any case: Is there a way to get different frames for every page in a random way? Using \startuseMPgraphic is the correct way, since you want the graphic to be recalculated every time. I have no clue why this fails at the moment. It works fine in older versions, so I assume it's a bug. Marco ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ Ok, thank you Marco. Hans, is this a bug? Has something changed? /Mikael ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] default parameter in \definefont
On Tue, 26 Feb 2013 10:04:38 -0500 john Culleton j...@wexfordpress.com wrote: On Tue, 26 Feb 2013 08:18:25 +0100 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Am 26.02.2013 um 00:00 schrieb john Culleton j...@wexfordpress.com: And the error messages indicate that MKIV cannot find those otf files but they exist in /usr/share/fonts/OTF. The run completes but other fonts and sizes are used for the title page. Solved my problem the ugly way. I moved the fonts to the directory where I was compiling the document. Added otf suffix to the \definefont file names. Now MKIV can find the fonts. A better solution is of course welcome. -- John Culleton Wexford Press Free list of books for self-publishers: http://wexfordpress.net/shortlist.html PDF e-book: Create Book Covers with Scribus available at http://www.booklocker.com/books/4055.html ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] default parameter in \definefont
On 2013–02–26 john Culleton wrote: files but they exist in /usr/share/fonts/OTF. The run completes but other fonts and sizes are used for the title page. Solved my problem the ugly way. I moved the fonts to the directory where I was compiling the document. Added otf suffix to the \definefont file names. Now MKIV can find the fonts. A better solution is of course welcome. ∙ Did you set OSFONTDIR? ∙ Does OSFONTDIR include /usr/share/fonts/OTF? ∙ Did you run mtxrun -script fonts -reload? ∙ Do these commands return the fonts? mtxrun -script fonts -list -all minion mtxrun -script fonts -list -all myriad Marco signature.asc Description: Digital signature ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] default parameter in \definefont
On Tue, 26 Feb 2013 17:55:07 +0100 Marco Patzer home...@lavabit.com wrote: On 2013___02___26 john Culleton wrote: files but they exist in /usr/share/fonts/OTF. The run completes but other fonts and sizes are used for the title page. Solved my problem the ugly way. I moved the fonts to the directory where I was compiling the document. Added otf suffix to the \definefont file names. Now MKIV can find the fonts. A better solution is of course welcome. ___ Did you set OSFONTDIR? ___ Does OSFONTDIR include /usr/share/fonts/OTF? ___ Did you run mtxrun -script fonts -reload? ___ Do these commands return the fonts? mtxrun -script fonts -list -all minion mtxrun -script fonts -list -all myriad Marco After working on the problem some more following the above the answers are yes to all. Now I will disassemble my kludges one by one to see at what point the doc stops working. My thanks to you and Wolfgang. -- John Culleton Wexford Press Free list of books for self-publishers: http://wexfordpress.net/shortlist.html PDF e-book: Create Book Covers with Scribus available at http://www.booklocker.com/books/4055.html ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Apparent error in wiki example
I copied verbatim the example found here: http://wiki.contextgarden.net/Simple_Typescript_Example This line caused an error: \setupencoding[default=uc] When I commented it out the doc ran fine. -- John Culleton Wexford Press Free list of books for self-publishers: http://wexfordpress.net/shortlist.html PDF e-book: Create Book Covers with Scribus available at http://www.booklocker.com/books/4055.html ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Apparent error in wiki example
Hi John! ···date: 2013-02-26, Tuesday···from: john Culleton··· I copied verbatim the example found here: http://wiki.contextgarden.net/Simple_Typescript_Example This line caused an error: \setupencoding[default=uc] These are instructions for MkII (and PostScript Type 1 fonts). You are most likely running MkIV (with an Open Type version of your font). How to write a typescript for OpenType Fonts is explained in the manual: http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf Btw. are you aware of Termes, which is an updated version of Nimbus? It also comes bundled with and configured for Context. Try \setupbodyfont[termes,10pt] \starttext whatever \stoptext Regards Philipp -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments pgpVE24mJ_3Pb.pgp Description: PGP signature ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Apparent error in wiki example
On Tue, 26 Feb 2013 19:33:03 +0100 Philipp Gesang philipp.ges...@alumni.uni-heidelberg.de wrote: Hi John! ···date: 2013-02-26, Tuesday···from: john Culleton··· I copied verbatim the example found here: http://wiki.contextgarden.net/Simple_Typescript_Example This line caused an error: \setupencoding[default=uc] These are instructions for MkII (and PostScript Type 1 fonts). You are most likely running MkIV (with an Open Type version of your font). How to write a typescript for OpenType Fonts is explained in the manual: http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf Btw. are you aware of Termes, which is an updated version of Nimbus? It also comes bundled with and configured for Context. Try \setupbodyfont[termes,10pt] \starttext whatever \stoptext Regards Philipp Thanks for your help. I just spotted another somewhat comic error. The typescript for Sans calls roman fonts and the typescript for Roman calls sans fonts. Sometimes even good old Homer nods -- John Culleton Wexford Press Free list of books for self-publishers: http://wexfordpress.net/shortlist.html PDF e-book: Create Book Covers with Scribus available at http://www.booklocker.com/books/4055.html ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] recalculate background on every page with \uniqueMPgraphic?
On 2/26/2013 4:46 PM, Mikael P. Sundqvist wrote: On Mon, Feb 18, 2013 at 10:53 AM, Marco Patzer home...@lavabit.com wrote: On 2013–02–18 Mikael P. Sundqvist wrote: Thank you Marco for giving a better example. I thought that uniqueMPgraphic meant it was redrawn everytime while useMPgraphic meant it was done once and then gave the same result everytime used. it's reused *when possible* depending on some characteristics (like width and height) http://thread.gmane.org/gmane.comp.tex.context/79507/focus=79538 In any case: Is there a way to get different frames for every page in a random way? Using \startuseMPgraphic is the correct way, since you want the graphic to be recalculated every time. I have no clue why this fails at the moment. It works fine in older versions, so I assume it's a bug. Marco ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ Ok, thank you Marco. Hans, is this a bug? Has something changed? I don't know .. no example /Mikael ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] recalculate background on every page with \uniqueMPgraphic?
On 2013–02–26 Hans Hagen wrote: Hans, is this a bug? Has something changed? I don't know .. no example I provided an example in http://www.ntg.nl/pipermail/ntg-context/2013/071552.html However, it seems to be fixed in a recent beta. At least it works for me. Marco signature.asc Description: Digital signature ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] recalculate background on every page with \uniqueMPgraphic?
Hi Mikael, your original example works for me with a current beta if you replace uniqueMPgraphic with useMPgraphic. Marco signature.asc Description: Digital signature ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Apparent error in wiki example
Am 26.02.2013 um 21:28 schrieb john Culleton j...@wexfordpress.com: Thanks for your help. I just spotted another somewhat comic error. The typescript for Sans calls roman fonts and the typescript for Roman calls sans fonts. ??? Wolfgang ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Apparent error in wiki example
···date: 2013-02-26, Tuesday···from: Wolfgang Schuster··· Am 26.02.2013 um 21:28 schrieb john Culleton j...@wexfordpress.com: Thanks for your help. I just spotted another somewhat comic error. The typescript for Sans calls roman fonts and the typescript for Roman calls sans fonts. ??? Wolfgang He’s referring to the wiki article cited earlier. Judging from these lines: \definefontsynonym [Serif] [name:nimbussanlregu] … / \definefontsynonym [Sans] [name:nimbusromno9lregu] it appears to be the case -- I don’t have the Nimbus fonts so I can’t verify. Philipp -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments pgptn_Q8sOPvd.pgp Description: PGP signature ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Apparent error in wiki example
Oes the code in the wiki article referred to earlier: Tue, 26 Feb 2013 22:28:22 +0100 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Am 26.02.2013 um 21:28 schrieb john Culleton j...@wexfordpress.com: Thanks for your help. I just spotted another somewhat comic error. The typescript for Sans calls roman fonts and the typescript for Roman calls sans fonts. ??? Wolfgang Here is the code from the wiki artticle referred to earlier: \starttypescript [serif] [nimbus] \definefontsynonym [Serif] [name:nimbussanlregu] \definefontsynonym [SerifBold] [name:nimbussanlbold] \definefontsynonym [SerifItalic] [name:nimbussanlreguital] \definefontsynonym [SerifSlanted][name:nimbussanlreguital] \definefontsynonym [SerifBoldItalic] [name:nimbussanlboldital] \definefontsynonym [SerifBoldSlanted][name:nimbussanlboldital] \definefontsynonym [SerifCaps] [name:nimbussanlregu] \stoptypescript \starttypescript [sans] [nimbus] \definefontsynonym [Sans] [name:nimbusromno9lregu] \definefontsynonym [SansBold] [name:nimbusromno9lbold] \definefontsynonym [SansItalic] [name:nimbusromno9lreguital] \definefontsynonym [SansSlanted][name:nimbusromno9lreguital] \definefontsynonym [SansBoldItalic] [name:nimbusromno9lboldital] \definefontsynonym [SansBoldSlanted][name:nimbusromno9lboldital] \definefontsynonym [SansCaps] [name:nimbusromno9lregu] \stoptypescript -- John Culleton Wexford Press Free list of books for self-publishers: http://wexfordpress.net/shortlist.html PDF e-book: Create Book Covers with Scribus available at http://www.booklocker.com/books/4055.html ___ 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 : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___