ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Ending strings with non-break space in lang-txt.lua
@ 2018-12-05 18:47 Marco Patzer
  2018-12-05 21:29 ` Alan Braslau
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Patzer @ 2018-12-05 18:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi!

I've got a few unfortunate line breaks in my documents. In particular, breaks
are introduced in between the string “page” and the number:

  See figure 1 at page
  2.

The reason is that many strings in lang-txt.lua end in a space, rather than a
non-break space:

  ["atpage"]={
   ["labels"]={
    …
    ["en"]="at page ",
    …

I fixed this by defining

  \setuplabeltext
    [en]
    [atpage=at page\nbsp]

So I wonder: Does it ever make sense to have a regular space at the end of
those commands? I just skimmed through the file and most, if not all, strings
ending in a space would actually benefit from having it replaced by a
non-break space IMO.

Example:

\def\pageref#1%%
  {\in{figure}[#1] \labeltext{atpage}\at[#1]}

\starttext
  \hsize 3cm
  See \pageref{foo}.

  \page \startplacefigure [reference=foo] \stopplacefigure
\stoptext

Marco
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Ending strings with non-break space in lang-txt.lua
  2018-12-05 18:47 Ending strings with non-break space in lang-txt.lua Marco Patzer
@ 2018-12-05 21:29 ` Alan Braslau
  2018-12-06  8:34   ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Braslau @ 2018-12-05 21:29 UTC (permalink / raw)
  To: Marco Patzer; +Cc: mailing list for ConTeXt users

On Wed, 5 Dec 2018 19:47:31 +0100
Marco Patzer <lists@homerow.info> wrote:

> Hi!
> 
> I've got a few unfortunate line breaks in my documents. In
> particular, breaks are introduced in between the string “page” and
> the number:
> 
>   See figure 1 at page
>   2.
> 
> The reason is that many strings in lang-txt.lua end in a space,
> rather than a non-break space:
> 
>   ["atpage"]={
>    ["labels"]={
>     …
>     ["en"]="at page ",
>     …
> 
> I fixed this by defining
> 
>   \setuplabeltext
>     [en]
>     [atpage=at page\nbsp]
> 
> So I wonder: Does it ever make sense to have a regular space at the
> end of those commands? I just skimmed through the file and most, if
> not all, strings ending in a space would actually benefit from having
> it replaced by a non-break space IMO.
> 
> Example:
> 
> \def\pageref#1%%
>   {\in{figure}[#1] \labeltext{atpage}\at[#1]}
> 
> \starttext
>   \hsize 3cm
>   See \pageref{foo}.
> 
>   \page \startplacefigure [reference=foo] \stopplacefigure
> \stoptext

I agree, it drives me
nuts to see p.
5 or in Figure
8 etc.


Also, how about:

\at{\labeltext{atpage}}[#1]

(and does this make the space in the label redundant?)
In any case it is a bit sloppy...

Alan
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Ending strings with non-break space in lang-txt.lua
  2018-12-05 21:29 ` Alan Braslau
@ 2018-12-06  8:34   ` Hans Hagen
  2018-12-06  9:26     ` Marco Patzer
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2018-12-06  8:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Alan Braslau, Marco Patzer

On 12/5/2018 10:29 PM, Alan Braslau wrote:
> On Wed, 5 Dec 2018 19:47:31 +0100
> Marco Patzer <lists@homerow.info> wrote:
> 
>> Hi!
>>
>> I've got a few unfortunate line breaks in my documents. In
>> particular, breaks are introduced in between the string “page” and
>> the number:
>>
>>    See figure 1 at page
>>    2.
>>
>> The reason is that many strings in lang-txt.lua end in a space,
>> rather than a non-break space:
>>
>>    ["atpage"]={
>>     ["labels"]={
>>      …
>>      ["en"]="at page ",
>>      …
>>
>> I fixed this by defining
>>
>>    \setuplabeltext
>>      [en]
>>      [atpage=at page\nbsp]
>>
>> So I wonder: Does it ever make sense to have a regular space at the
>> end of those commands? I just skimmed through the file and most, if
>> not all, strings ending in a space would actually benefit from having
>> it replaced by a non-break space IMO.
>>
>> Example:
>>
>> \def\pageref#1%%
>>    {\in{figure}[#1] \labeltext{atpage}\at[#1]}
>>
>> \starttext
>>    \hsize 3cm
>>    See \pageref{foo}.
>>
>>    \page \startplacefigure [reference=foo] \stopplacefigure
>> \stoptext
> 
> I agree, it drives me
> nuts to see p.
> 5 or in Figure
> 8 etc.
> 
> 
> Also, how about:
> 
> \at{\labeltext{atpage}}[#1]

indeed, that is the command to use

> (and does this make the space in the label redundant?)
> In any case it is a bit sloppy...
can you experiment with this

\unexpanded\def\leftofreferencecontent
   {\removeunwantedspaces
    \nobreakspace
    \ignorespaces}



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Ending strings with non-break space in lang-txt.lua
  2018-12-06  8:34   ` Hans Hagen
@ 2018-12-06  9:26     ` Marco Patzer
  2018-12-06  9:44       ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Patzer @ 2018-12-06  9:26 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

On Thu, 6 Dec 2018 09:34:57 +0100
Hans Hagen <j.hagen@xs4all.nl> wrote:

> > Also, how about:
> > 
> > \at{\labeltext{atpage}}[#1]  
> 
> indeed, that is the command to use

Don't get too hung up on that command. That was just a quick way to
demonstrate the point and create an MWE.

> can you experiment with this
> 
> \unexpanded\def\leftofreferencecontent
>    {\removeunwantedspaces
>     \nobreakspace
>     \ignorespaces}

This fixes the MWE, but it doesn't prevent all "unfortunate" line
breaks caused by the spaces. At least it doesn't if \labeltext is
used separately to obtain the translated strings.

Currently I use (in one of my modules):

  \def\foo{\labeltext\v!atpage\currentreferencepage}

This works (as by your suggestion):

  \def\foo{\labeltext\v!atpage
    \removeunwantedspaces\nobreakspace\ignorespaces
    \currentreferencepage}

Which basically replaces the space with a non-break space after the
fact.

So I wonder if it's not a better solution to fix the initial
definitions. But I might be mistaken or I'm overlooking something
where this might cause issues.

Marco
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Ending strings with non-break space in lang-txt.lua
  2018-12-06  9:26     ` Marco Patzer
@ 2018-12-06  9:44       ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2018-12-06  9:44 UTC (permalink / raw)
  To: Marco Patzer; +Cc: mailing list for ConTeXt users

On 12/6/2018 10:26 AM, Marco Patzer wrote:
> On Thu, 6 Dec 2018 09:34:57 +0100
> Hans Hagen <j.hagen@xs4all.nl> wrote:
> 
>>> Also, how about:
>>>
>>> \at{\labeltext{atpage}}[#1]
>>
>> indeed, that is the command to use
> 
> Don't get too hung up on that command. That was just a quick way to
> demonstrate the point and create an MWE.
> 
>> can you experiment with this
>>
>> \unexpanded\def\leftofreferencecontent
>>     {\removeunwantedspaces
>>      \nobreakspace
>>      \ignorespaces}
> 
> This fixes the MWE, but it doesn't prevent all "unfortunate" line
> breaks caused by the spaces. At least it doesn't if \labeltext is
> used separately to obtain the translated strings.
> 
> Currently I use (in one of my modules):
> 
>    \def\foo{\labeltext\v!atpage\currentreferencepage}
> 
> This works (as by your suggestion):
> 
>    \def\foo{\labeltext\v!atpage
>      \removeunwantedspaces\nobreakspace\ignorespaces
>      \currentreferencepage}
> 
> Which basically replaces the space with a non-break space after the
> fact.
> 
> So I wonder if it's not a better solution to fix the initial
> definitions. But I might be mistaken or I'm overlooking something
> where this might cause issues.
it then interferes with mechanisms that inject spaces themselves (as 
\at{...}[]

(i'll add am auto check space and replace by nonbreak space trick)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

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

end of thread, other threads:[~2018-12-06  9:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-05 18:47 Ending strings with non-break space in lang-txt.lua Marco Patzer
2018-12-05 21:29 ` Alan Braslau
2018-12-06  8:34   ` Hans Hagen
2018-12-06  9:26     ` Marco Patzer
2018-12-06  9:44       ` Hans Hagen

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