ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Extraneous spaces in XML documents
@ 2003-02-10  2:58 Robbie Pickering
  2003-02-10  9:26 ` Hans Hagen
  2003-02-10 22:05 ` Simon Pepping
  0 siblings, 2 replies; 7+ messages in thread
From: Robbie Pickering @ 2003-02-10  2:58 UTC (permalink / raw)



I'm typesetting some XML text with comments in and for the working
version the comments are to go in the margin. For the final version the
comments are simply to be ignored.

In the end result there is a noticeably larger space between the words
where the comma had been. Apparently more than one space is reaching
TeX's stomach, though it's beyond me to work out how.

I suppose I need a more sophisticated \gobble definition than the
simple TeXbook one, yes?


----file minimal.tex



%now we will map XML arguments to context ones.

\defineXMLargument [title] \title
\defineXMLargument [footnote] \footnote
\defineXMLargument [section] \section  % et cetera....

% this definition for drafts where comments are printed 
%in the margin
%\defineXMLargument [comment] \inmargin

%this definition for the final version where the
% remaining comments are ignored

\def\gobble#1{}

\defineXMLargument [comment] \gobble


\starttext

\processXMLfilegrouped {sample.xml}

\stoptext



--- file sample.xml

<article>
<title>Nonsense</title>
<text>

<section>A section
</section>


Makes complicated pages by starting with simple individual characters
and putting them together in larger units, and putting these together
<comment>what does he mean here, putting these together???</comment> in
still larger units, and so on. Conceptually, it's a big paste-up
job.<footnote>From The TeXbook.</footnote>

</text>
</article>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Extraneous spaces in XML documents
  2003-02-10  2:58 Extraneous spaces in XML documents Robbie Pickering
@ 2003-02-10  9:26 ` Hans Hagen
  2003-02-10 18:11   ` Robbie Pickering
  2003-02-10 22:05 ` Simon Pepping
  1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2003-02-10  9:26 UTC (permalink / raw)


At 02:58 AM 2/10/2003 +0000, you wrote:

>I'm typesetting some XML text with comments in and for the working
>version the comments are to go in the margin. For the final version the
>comments are simply to be ignored.
>
>In the end result there is a noticeably larger space between the words
>where the comma had been. Apparently more than one space is reaching
>TeX's stomach, though it's beyond me to work out how.
>
>I suppose I need a more sophisticated \gobble definition than the
>simple TeXbook one, yes?
>
>
>----file minimal.tex
>
>
>
>%now we will map XML arguments to context ones.
>
>\defineXMLargument [title] \title
>\defineXMLargument [footnote] \footnote
>\defineXMLargument [section] \section  % et cetera....
>
>% this definition for drafts where comments are printed
>%in the margin
>%\defineXMLargument [comment] \inmargin
>
>%this definition for the final version where the
>% remaining comments are ignored
>
>\def\gobble#1{}
>
>\defineXMLargument [comment] \gobble

you can use \gobbleoneargument here

the next solution may help:

\defineXMLargument [comment] \XMLhideelement

\long\def\XMLhideelement#1%
   {\futurelet\nexttoken\doXMLhideelement}

\def\doXMLhideelement
   {\ifx\nexttoken\blankspace\removeunwantedspaces\fi}

maybe i will add something \defineXMLhide; will think about it

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Extraneous spaces in XML documents
  2003-02-10  9:26 ` Hans Hagen
@ 2003-02-10 18:11   ` Robbie Pickering
  0 siblings, 0 replies; 7+ messages in thread
From: Robbie Pickering @ 2003-02-10 18:11 UTC (permalink / raw)


Hans Hagen wrote:
>At 02:58 AM 2/10/2003 +0000, you wrote:
>
>
>>%this definition for the final version where the
>>% remaining comments are ignored
>>
>>\def\gobble#1{}
>>
>>\defineXMLargument [comment] \gobble
>
>you can use \gobbleoneargument here


Actually, \gobbleoneargument doesn't make any difference, but the
\XMLhideelement solution works perfectly. thanks

robbie

>
>the next solution may help:
>
>\defineXMLargument [comment] \XMLhideelement
>
>\long\def\XMLhideelement#1%
>   {\futurelet\nexttoken\doXMLhideelement}
>
>\def\doXMLhideelement
>   {\ifx\nexttoken\blankspace\removeunwantedspaces\fi}
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Extraneous spaces in XML documents
  2003-02-10  2:58 Extraneous spaces in XML documents Robbie Pickering
  2003-02-10  9:26 ` Hans Hagen
@ 2003-02-10 22:05 ` Simon Pepping
  2003-02-11 13:30   ` Robbie Pickering 
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Pepping @ 2003-02-10 22:05 UTC (permalink / raw)


On Mon, Feb 10, 2003 at 02:58:25AM +0000, Robbie Pickering wrote:
> 
> I'm typesetting some XML text with comments in and for the working
> version the comments are to go in the margin. For the final version the
> comments are simply to be ignored.
> 
> In the end result there is a noticeably larger space between the words
> where the comma had been. Apparently more than one space is reaching
> TeX's stomach, though it's beyond me to work out how.
> 
> \defineXMLargument [comment] \gobble

You should use \ignorespaces in the end tag. Unfortunately,
\defineXMLargument does not allow you to define the action for the end
tag. This would work:

\defineXMLenvironmentsave [comment] {} {\ignorespaces}

The save action gobbles the content as well.

Regards, Simon

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Extraneous spaces in XML documents
  2003-02-10 22:05 ` Simon Pepping
@ 2003-02-11 13:30   ` Robbie Pickering 
  2003-02-11 20:18     ` Hans Hagen
  2003-02-14 20:17     ` Simon Pepping
  0 siblings, 2 replies; 7+ messages in thread
From: Robbie Pickering  @ 2003-02-11 13:30 UTC (permalink / raw)


Simon Pepping wrote:
>On Mon, Feb 10, 2003 at 02:58:25AM +0000, Robbie Pickering wrote:
>> 
>> I'm typesetting some XML text with comments in and for the working
>> version the comments are to go in the margin. For the final version the
>> comments are simply to be ignored.
>> 
>> In the end result there is a noticeably larger space between the words
>> where the comma had been. Apparently more than one space is reaching
>> TeX's stomach, though it's beyond me to work out how.
>> 
>> \defineXMLargument [comment] \gobble
>
>You should use \ignorespaces in the end tag. Unfortunately,
>\defineXMLargument does not allow you to define the action for the end
>tag. This would work:
>
>\defineXMLenvironmentsave [comment] {} {\ignorespaces}
>
>The save action gobbles the content as well.
>
>Regards, Simon
>

Thanks.
Is this conceptually different to writing

\def\gobble#1{\ignorespaces}
\defineXMLargument [comment] \gobble

?


It seems to have the effect of also devouring the necessary space after
a full stop, if the comment tag comes directly after it in the source:

Makes complicated pages by starting.<comment>This is not a proper
sentence.</comment> With simple ...

The space after the comment, before "With" should get into the final
document, but doesn't make it. (on the other hand, this also happens
when the comments are shown with

\defineXMLargument [comment] \inmargin



cheers, robbie

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Extraneous spaces in XML documents
  2003-02-11 13:30   ` Robbie Pickering 
@ 2003-02-11 20:18     ` Hans Hagen
  2003-02-14 20:17     ` Simon Pepping
  1 sibling, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2003-02-11 20:18 UTC (permalink / raw)


At 01:30 PM 2/11/2003 +0000, you wrote:

>Thanks.
>Is this conceptually different to writing
>
>\def\gobble#1{\ignorespaces}
>\defineXMLargument [comment] \gobble

kind of, in tex mode, it gobble spaces and takes the next argument or token

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Extraneous spaces in XML documents
  2003-02-11 13:30   ` Robbie Pickering 
  2003-02-11 20:18     ` Hans Hagen
@ 2003-02-14 20:17     ` Simon Pepping
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Pepping @ 2003-02-14 20:17 UTC (permalink / raw)


On Tue, Feb 11, 2003 at 01:30:50PM +0000, Robbie Pickering  wrote:
> Simon Pepping wrote:
> >You should use \ignorespaces in the end tag. Unfortunately,
> >\defineXMLargument does not allow you to define the action for the end
> >tag. This would work:
> >
> >\defineXMLenvironmentsave [comment] {} {\ignorespaces}
> >
> >The save action gobbles the content as well.
> >
> >Regards, Simon
> >
> 
> Thanks.
> Is this conceptually different to writing
> 
> \def\gobble#1{\ignorespaces}
> \defineXMLargument [comment] \gobble

No, that seems to be the same thing, and a good way to do it. I missed
that.

> It seems to have the effect of also devouring the necessary space after
> a full stop, if the comment tag comes directly after it in the source:
> 
> Makes complicated pages by starting.<comment>This is not a proper
> sentence.</comment> With simple ...
> 
> The space after the comment, before "With" should get into the final
> document, but doesn't make it. (on the other hand, this also happens
> when the comments are shown with

Yea, that is the problem. If you remove the spaces, you do it
everywhere. 

I think it would be a better solution if you write your document
carefully, and not gobble the spaces:

Makes complicated pages by starting. <comment>This is not a proper
sentence. </comment>With simple ...

Simon

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-02-14 20:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-10  2:58 Extraneous spaces in XML documents Robbie Pickering
2003-02-10  9:26 ` Hans Hagen
2003-02-10 18:11   ` Robbie Pickering
2003-02-10 22:05 ` Simon Pepping
2003-02-11 13:30   ` Robbie Pickering 
2003-02-11 20:18     ` Hans Hagen
2003-02-14 20:17     ` Simon Pepping

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