From: massifr@fastwebnet.it
To: ntg-context@ntg.nl
Subject: passing the \starttabulate format in XML typesetting
Date: Thu, 16 Jun 2016 15:16:20 +0200 [thread overview]
Message-ID: <1895019.ZrvyDbYmld@max> (raw)
Hello list,
I'm trying to map HTML with tabs to \starttabulate in ConTeXt.
A div of class "tabulate" is mapped to a \starttabulate ... \stoptabulate section,
p elements are rows and span elements of class "tab" produce \NCs in ConTeXt.
That div element has a "format" attribute that must be passed to \starttabulate[...]
to format the columns.
I managed to pass that attribute using lua, but I failed using only ConTeXt:
\startbuffer[test]
<text>
<div class="tabulate" format="|lw(2cm)|cw(2cm)|rw(2cm)|">
<p>a<span class="tab"> </span>b<span class="tab"> </span>c</p>
</div>
</text>
\stopbuffer
\startxmlsetups xml:somesetups
\xmlsetsetup{#1}{text}{xml:text}
\xmlsetsetup{#1}{div[@class='tabulate']}{xml:div:tabulate}
\xmlsetsetup{#1}{div[@class='tabulate']/p}{xml:div:tabulate:p}
\xmlsetsetup{#1}{div[@class='tabulate']/p/span[@class='tab']}{xml:div:tabulate:p:tab}
\stopxmlsetups
\xmlregistersetup{xml:somesetups}
\startxmlsetups xml:text
\indenting[{yes,first,12pt}]
\xmlflush{#1}
\stopxmlsetups
\setuptabulation[rulethickness=1pt,unit=2pt]
\ctxlua{
function xml.functions.divTabulate(t)
local format = xml.attribute(t, "", "format")
context.starttabulate( { format } )
lxml.flush(t)
context.stoptabulate()
end
}
\startxmlsetups xml:div:tabulate
% \xmlfunction{#1}{divTabulate} % this works!
% the following line can't pass the format correctly to ConTeXt
\starttabulate[{\xmlatt{#1}{format}}]
\xmlflush{#1}
\stoptabulate
\stopxmlsetups
\startxmlsetups xml:div:tabulate:p
\NC{}\xmlflush{#1}\NC\NR
\stopxmlsetups
\startxmlsetups xml:div:tabulate:p:tab
\NC{}
\stopxmlsetups
\starttext
\xmlprocessbuffer{main}{test}{}
\stoptext
I suspect it's a simple mistake of mine.
Thanks in advance,
Massi
___________________________________________________________________________________
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
___________________________________________________________________________________
reply other threads:[~2016-06-16 13:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1895019.ZrvyDbYmld@max \
--to=massifr@fastwebnet.it \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).