* xtables and xml and lua
@ 2014-06-18 11:03 Thomas A. Schmitz
2014-06-18 14:32 ` Hans Hagen
0 siblings, 1 reply; 3+ messages in thread
From: Thomas A. Schmitz @ 2014-06-18 11:03 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]
Hi all,
I'm terribly sorry I have to send three files for this test case, but
I'm trying to process xml with lua, so it's difficult to do otherwise. I
have two problems:
1. (probably unrelated to xml/lua): when I try to set the options (l.
22-3 in test-style.tex)
\setupxtable [split=yes,
spaceinbetween=medium]
for the xtable environment, I get an error:
tex error > error on line 22 in file
/mnt/shared/context/tex/texmf-context/tex/context/base/cont-yes.mkiv: !
You can't use `\prevdepth' in horizontal mode
\nointerlineskip ^^@-\prevdepth
-\thousandpoint
l.22 \nointerlineskip
\ctxcommand #1o-\directlua {commands.#1}
\tabl_x_process ...lse \tabl_x_flush_text_checked
\fi \fi \ctxcommand
{x_tab...
l.8 }
\ctxlxml #1h-\ctxlua {lxml.#1}
...
l.91 \stopluacode
This looks like a buglet in xtables to me.
2. I would like to test whether a certain element has already been seen
(l. 8-13 in test-style.lua). However, since tables are two-pass, the
test will always return "true." How could I test properly?
Thanks for your patience!
Thomas
[-- Attachment #2: test.zip --]
[-- Type: application/zip, Size: 971 bytes --]
[-- Attachment #3: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: xtables and xml and lua
2014-06-18 11:03 xtables and xml and lua Thomas A. Schmitz
@ 2014-06-18 14:32 ` Hans Hagen
2014-06-18 18:18 ` Thomas A. Schmitz
0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2014-06-18 14:32 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
On 6/18/2014 1:03 PM, Thomas A. Schmitz wrote:
> Hi all,
>
> I'm terribly sorry I have to send three files for this test case, but
> I'm trying to process xml with lua, so it's difficult to do otherwise. I
> have two problems:
>
> 1. (probably unrelated to xml/lua): when I try to set the options (l.
> 22-3 in test-style.tex)
>
> \setupxtable [split=yes,
> spaceinbetween=medium]
>
> for the xtable environment, I get an error:
>
> tex error > error on line 22 in file
> /mnt/shared/context/tex/texmf-context/tex/context/base/cont-yes.mkiv: !
> You can't use `\prevdepth' in horizontal mode
>
>
> \nointerlineskip ^^@-\prevdepth
> -\thousandpoint
> l.22 \nointerlineskip
>
> \ctxcommand #1o-\directlua {commands.#1}
>
> \tabl_x_process ...lse \tabl_x_flush_text_checked
> \fi \fi \ctxcommand
> {x_tab...
> l.8 }
>
> \ctxlxml #1h-\ctxlua {lxml.#1}
>
> ....
> l.91 \stopluacode
>
> This looks like a buglet in xtables to me.
>
> 2. I would like to test whether a certain element has already been seen
> (l. 8-13 in test-style.lua). However, since tables are two-pass, the
> test will always return "true." How could I test properly?
many ways ... (ok, i might provide some hook into tables) ... three
attached
i bet you'll choose the third solution
Hans
-----------------------------------------------------------------
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
-----------------------------------------------------------------
[-- Attachment #2: test.xml --]
[-- Type: text/xml, Size: 259 bytes --]
<?xml version="1.0" encoding="utf-8"?>
<a>
<b> <c>1</c> <d>Text</d> </b>
<b> <c>2</c> <d>More text</d> </b>
<b> <c>2</c> <d>Even more text</d> </b>
<b> <c>2</c> <d>And more</d> </b>
<b> <c>3</c> <d>And even more</d> </b>
</a>
[-- Attachment #3: test-style.lua --]
[-- Type: text/plain, Size: 1719 bytes --]
-- solution 1
-- local lasttitle = nil
--
-- function xml.functions.test_b(t)
-- local title = xml.text(t, "c")
-- local content = xml.text(t, "d")
-- context.startxrow()
-- context.startxcell( { background="color", backgroundcolor="yellow" } )
-- if lasttitle == title then
-- context.color( { "red" }, title)
-- else
-- lasttitle = title
-- context.color( { "blue" }, title)
-- end
-- context.stopxcell()
-- context.startxcell()
-- context(content)
-- context.stopxcell()
-- context.stopxrow()
-- end
-- solution 2
-- local titles = { }
--
-- function xml.functions.reset_b(t)
-- titles = { }
-- end
--
-- function xml.functions.test_b(t)
-- local title = xml.text(t, "c")
-- local content = xml.text(t, "d")
-- context.startxrow()
-- context.startxcell( { background="color", backgroundcolor="yellow" } )
-- if titles[title] then
-- context.color( { "red" }, title)
-- else
-- titles[title] = true
-- context.color( { "blue" }, title)
-- end
-- context.stopxcell()
-- context.startxcell()
-- context(content)
-- context.stopxcell()
-- context.stopxrow()
-- end
-- solution 3
function xml.functions.test_b(t)
local title = xml.text(t, "c")
local content = xml.text(t, "d")
context.startxrow()
context.startxcell( { background="color", backgroundcolor="yellow" } )
if xml.text(t,"./preceding-sibling::/[-1]") == title then
context.color( { "red" }, title)
else
context.color( { "blue" }, title)
end
context.stopxcell()
context.startxcell()
context(content)
context.stopxcell()
context.stopxrow()
end
[-- Attachment #4: test-style.tex --]
[-- Type: application/x-tex, Size: 758 bytes --]
[-- Attachment #5: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: xtables and xml and lua
2014-06-18 14:32 ` Hans Hagen
@ 2014-06-18 18:18 ` Thomas A. Schmitz
0 siblings, 0 replies; 3+ messages in thread
From: Thomas A. Schmitz @ 2014-06-18 18:18 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 18 Jun 2014, at 16:32, Hans Hagen <pragma@wxs.nl> wrote:
> many ways ... (ok, i might provide some hook into tables) ... three attached
>
> i bet you'll choose the third solution
Thanks a lot Hans! In fact, I like solution 2 best - it’s something that should’ve occurred to me too. But I’ve been running into similar problems, so it’s good to know more than one way around them!
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-06-18 18:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 11:03 xtables and xml and lua Thomas A. Schmitz
2014-06-18 14:32 ` Hans Hagen
2014-06-18 18:18 ` Thomas A. Schmitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).