From: Wolfgang Schuster via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
Denis Maier via ntg-context <ntg-context@ntg.nl>
Cc: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
Subject: Re: XML, dealing with whitespace
Date: Sat, 15 Jan 2022 20:28:00 +0100 [thread overview]
Message-ID: <bee36fda-7ad2-0a53-e0ae-7112c956dd76@gmail.com> (raw)
In-Reply-To: <02468648b859479c9f5bbcce7001e88b@unibe.ch>
[-- Attachment #1.1: Type: text/plain, Size: 1522 bytes --]
Denis Maier via ntg-context schrieb am 15.01.2022 um 13:04:
>
> Hi all,
>
> I have sources that look like this:
>
> %%%%%%%%%%%%%%%%%%%%%
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <article>
>
> <p>Bla Bla Bla</p>
>
> <p>
>
> <underline>
>
> <italic>Bla</italic>
>
> </underline>, Bla Bla.</p>
>
> </article>
>
> %%%%%%%%%%%%%%%%%%%%%
>
> Typesetting this with context gives me a spurious space after the
> underlined Bla in italics.
>
There is no spurious space, the line break is just converted to a space
and I see no reason why this shouldn't happen. To remove space before or
after certain parts of text within a paragraph you can use the
\removeunwantedspace and \ignorespaces commands.
%%%% begin example
\starttexdefinition RemovePreceding #1
\removeunwantedspaces
#1
\stoptexdefinition
\starttexdefinition RemoveFollowing #1
#1
\ignorespaces
\stoptexdefinition
\starttext
Bla \RemovePreceding{Bla} Bla
Bla \RemoveFollowing{Bla} Bla
\stoptext
%%%% end example
When only following spaces are a problem a better alternative to
\ignorespace is \autoinsertnextspace which checks the following token
which ensures there is space when the next character is punctuation.
%%%% begin example
\starttexdefinition Italic #1
\emphasized{#1}
\autoinsertnextspace
\stoptexdefinition
\starttexdefinition Underbar #1
\underbar{#1}
\stoptexdefinition
\starttext
Bla Bla Bla
\Underbar{\Italic{Bla} , Bla Bla.}
\stoptext
%%%% end example
Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 3941 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2022-01-15 19:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-15 12:04 Denis Maier via ntg-context
2022-01-15 19:28 ` Wolfgang Schuster via ntg-context [this message]
2022-01-17 9:47 ` Denis Maier via ntg-context
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=bee36fda-7ad2-0a53-e0ae-7112c956dd76@gmail.com \
--to=ntg-context@ntg.nl \
--cc=wolfgang.schuster.lists@gmail.com \
/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).