ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* passing the \starttabulate format in XML typesetting
@ 2016-06-16 13:16 massifr
  0 siblings, 0 replies; only message in thread
From: massifr @ 2016-06-16 13:16 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-16 13:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-16 13:16 passing the \starttabulate format in XML typesetting massifr

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).