Extraneous spaces in XML documents
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>
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 -------------------------------------------------------------------------
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}
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
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
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 -------------------------------------------------------------------------
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
participants (4)
-
drymartini@gmx.de
-
Hans Hagen
-
robbieinsel@freeuk.com
-
Simon Pepping