Re: [NTG-context] t-vim module: math in "normal" code and background color

2017-07-17 Thread Aditya Mahajan

On Mon, 17 Jul 2017, Gerion Entrup wrote:


Hi,

I have two questions with the vim module.

1. I want to use the math mode inside the code. I've seen the escape option, 
e.g. here [1], but this seems to work only with comments. Is there a 
possibility to use it directly in the code, too?


Short answer. No.

Long answer. t-vim relies on vim to syntax highlight the code. Since the 
code is not valid python, the default python syntax highlighting will not 
work. In principle, it is possible to write a vim syntax highlighting 
script for a derivative of python where math terms are allowed, but that 
requires a lot of work for each language. The whole point of t-vim module 
was that I am lazy and don't want to write the parser for each language 
:-)



Minimal example:
```
\usemodule[vim]
\definevimtyping[python][syntax=python, escape=on]

\starttext
\startpython
# Returns \m{\sum_{i=1}^{n}i}
def sum_upto(\m{n \in \mathbb{N}})
   r = range(1, \m{n} + 1)
   return sum(r)
\stoppython
\stoptext
```


Another option will be to use the algorithmic module: 
https://bitbucket.org/wolfs/algorithmic/src/

2. It would be cool, if I can define some background color for the code. 
Unfortunately I'm very new to context and haven't seen a direct option. I 
assume this is possible with some kind of extra environment around the code?


You can add

\setupbackground[background=color, backgroundcolor=gray]

\setupvimtyping[python]
[
  before={\startbackground},
  after={\stopbackground},
]

or, instead of modifying the default background, define a new background 
and use that.


Aditya
___
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
___

Re: [NTG-context] t-vim module: math in "normal" code and background color

2017-07-17 Thread Henri Menke
On Mon, 2017-07-17 at 21:13 +0200, Gerion Entrup wrote:
> Hi,
> 
> I have two questions with the vim module.
> 
> 1. I want to use the math mode inside the code. I've seen the escape option, 
> e.g. here [1], but this seems to work only with comments. Is there a 
> possibility to use it directly in the code, too?
> 
> Minimal example:
> ```
> \usemodule[vim]
> \definevimtyping[python][syntax=python, escape=on]
> 
> \starttext
> \startpython
> # Returns \m{\sum_{i=1}^{n}i}
> def sum_upto(\m{n \in \mathbb{N}})
> r = range(1, \m{n} + 1)
> return sum(r)
> \stoppython
> \stoptext
> ```
> 
> 2. It would be cool, if I can define some background color for the code. 
> Unfortunately I'm very new to context and haven't seen a direct option. I 
> assume this is possible with some kind of extra environment around the code?

Background is no problem, escape in code is not implemented in t-vim.  I filed 
a feature request for
/BTEX ... /ETEX escaping as in regular typing on Aditya's GitHub: 
https://github.com/adityam/filter/
issues/23


\definetextbackground
  [verbatim]
  [location=paragraph]

\usemodule[vim]

\definevimtyping
  [python]
  [syntax=python,
   escape=on,
   before={\starttextbackground[verbatim]},
   after={\stoptextbackground}]

\setuptyping
  [before={\starttextbackground[verbatim]},
   after={\stoptextbackground}]

\starttext

\starttyping[escape=yes]
# Returns /BTEX\m{\sum_{i=1}^{n}i}/ETEX
def sum_upto(/BTEX\m{n \in \mathbb{N}}/ETEX)
r = range(1, \m{n} + 1)
return sum(r)
\stoptyping

\startpython
# Returns \m{\sum_{i=1}^{n}i}
def sum_upto(\m{n \in \mathbb{N}}w)
r = range(1, \m{n} + 1)
return sum(r)
\stoppython

\stoptext


> (I've subscribed the list, so you don't have to CC me.)
> 
> Thank you in advance,
> Gerion
> 
> ___
> 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
> ___
___
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
___

Re: [NTG-context] fixed spacing

2017-07-17 Thread Floris van Manen
No, i don’t want them in a table in columns.
Rather i want the stretching space after the comma only.

.F


> On 17 Jul 2017, at 22:05, Rik Kabel  wrote:
> 
> On 2017-07-17 15:23, Floris van Manen wrote:
>> dear List,
>> 
>> I try to put a set of numbers into a block text.
>> I want to keep the spacing within the items fixed
>> x-y:~z,
>> How do i do that?
>> The attached code does not seem to treat the fixed space as fixed.
>> 
>> Thanks
>> .Floris
>> 
>> 
>> \definepapersize[iiwii][width=125mm, height=125mm]
>> \setuppapersize[iiwii]
>> \setupbodyfont[7pt]
>> \setuplayout[backspace=3mm,
>> topspace=3mm,
>> width=70mm,
>> header=0mm,
>> footer=0mm,
>> height=119mm]
>> \starttext
>> 
>> \starttext
>> {\tfxx\framed[width=42mm,align={width,nothyphenated,verytolerant},frame=off]
>> {0-1:~28, 1-2:~1686, 0-2:~1710, 8-9:~3484, 7-8:~15862, 7-9:~17152, 
>> 1-3:~90632, 0-3:~90645, 2-3:~90840, 7-6:~98762, 6-8:~100082, 6-9:~103544, 
>> 4-0:~106926, 4-1:~106949, 4-2:~107546, 4-3:~192211, 3-6:~990165, 
>> 2-6:~1040810, 3-7:~1041891, 1-6:~1042032, 0-6:~1042060, 3-8:~1055123, 
>> 3-9:~1057765, 2-7:~1086097, 1-7:~1087411, 0-7:~1087439, 2-8:~1099942, 
>> 1-8:~1101249, 0-8:~1101277, 2-9:~1102409, 1-9:~1103718, 0-9:~1103746, 
>> 4-6:~1138989, 4-7:~1180436, 4-8:~1194617, 4-9:~1196971, 5-3:~1729640, 
>> 4-5:~1756438, 5-0:~1761922, 5-1:~1761941, 5-2:~1763565, 5-6:~2459757, 
>> 5-7:~2548510, 5-8:~2555440, 5-9:~2558871
>> }}
>> 
>> {\tfxx\framed[width=42mm,align={width,nothyphenated},frame=off]
>> {0-1:~28, 1-2:~1686, 0-2:~1710, 8-9:~3484, 7-8:~15862, 7-9:~17152, 
>> 1-3:~90632, 0-3:~90645, 2-3:~90840, 7-6:~98762, 6-8:~100082, 6-9:~103544, 
>> 4-0:~106926, 4-1:~106949, 4-2:~107546, 4-3:~192211, 3-6:~990165, 
>> 2-6:~1040810, 3-7:~1041891, 1-6:~1042032, 0-6:~1042060, 3-8:~1055123, 
>> 3-9:~1057765, 2-7:~1086097, 1-7:~1087411, 0-7:~1087439, 2-8:~1099942, 
>> 1-8:~1101249, 0-8:~1101277, 2-9:~1102409, 1-9:~1103718, 0-9:~1103746, 
>> 4-6:~1138989, 4-7:~1180436, 4-8:~1194617, 4-9:~1196971, 5-3:~1729640, 
>> 4-5:~1756438, 5-0:~1761922, 5-1:~1761941, 5-2:~1763565, 5-6:~2459757, 
>> 5-7:~2548510, 5-8:~2555440, 5-9:~2558871
>> }}
>> 
>> \stoptext
>> 
> 
>   • Use tabular numbers and hard-code all of the spaces you need:
> \definefontfeature[default][default][tnum=yes]
> or
> \definefontfeature[ff:tnum][tnum=yes] ... \addff{ff:tnum} or 
> \feature[+][ff:tnum] where appropriate.
> 
>   • Put the numbers in a table and right-align the number columns (see 
> http://wiki.contextgarden.net/TABLE#Using_character_alignment if you need 
> decimal alignment).
> --
> Rik
>   • Both
> 
> =
> ___
> 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
> ___



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
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
___

Re: [NTG-context] fixed spacing

2017-07-17 Thread Rik Kabel

On 2017-07-17 15:23, Floris van Manen wrote:

dear List,

I try to put a set of numbers into a block text.
I want to keep the spacing within the items fixed
x-y:~z,
How do i do that?
The attached code does not seem to treat the fixed space as fixed.

Thanks
.Floris


\definepapersize[iiwii][width=125mm, height=125mm]
\setuppapersize[iiwii]
\setupbodyfont[7pt]
\setuplayout[backspace=3mm,
 topspace=3mm,
 width=70mm,
 header=0mm,
 footer=0mm,
 height=119mm]
\starttext

\starttext
{\tfxx\framed[width=42mm,align={width,nothyphenated,verytolerant},frame=off]
{0-1:~28, 1-2:~1686, 0-2:~1710, 8-9:~3484, 7-8:~15862, 7-9:~17152, 1-3:~90632, 
0-3:~90645, 2-3:~90840, 7-6:~98762, 6-8:~100082, 6-9:~103544, 4-0:~106926, 
4-1:~106949, 4-2:~107546, 4-3:~192211, 3-6:~990165, 2-6:~1040810, 3-7:~1041891, 
1-6:~1042032, 0-6:~1042060, 3-8:~1055123, 3-9:~1057765, 2-7:~1086097, 
1-7:~1087411, 0-7:~1087439, 2-8:~1099942, 1-8:~1101249, 0-8:~1101277, 
2-9:~1102409, 1-9:~1103718, 0-9:~1103746, 4-6:~1138989, 4-7:~1180436, 
4-8:~1194617, 4-9:~1196971, 5-3:~1729640, 4-5:~1756438, 5-0:~1761922, 
5-1:~1761941, 5-2:~1763565, 5-6:~2459757, 5-7:~2548510, 5-8:~2555440, 
5-9:~2558871
}}

{\tfxx\framed[width=42mm,align={width,nothyphenated},frame=off]
{0-1:~28, 1-2:~1686, 0-2:~1710, 8-9:~3484, 7-8:~15862, 7-9:~17152, 1-3:~90632, 
0-3:~90645, 2-3:~90840, 7-6:~98762, 6-8:~100082, 6-9:~103544, 4-0:~106926, 
4-1:~106949, 4-2:~107546, 4-3:~192211, 3-6:~990165, 2-6:~1040810, 3-7:~1041891, 
1-6:~1042032, 0-6:~1042060, 3-8:~1055123, 3-9:~1057765, 2-7:~1086097, 
1-7:~1087411, 0-7:~1087439, 2-8:~1099942, 1-8:~1101249, 0-8:~1101277, 
2-9:~1102409, 1-9:~1103718, 0-9:~1103746, 4-6:~1138989, 4-7:~1180436, 
4-8:~1194617, 4-9:~1196971, 5-3:~1729640, 4-5:~1756438, 5-0:~1761922, 
5-1:~1761941, 5-2:~1763565, 5-6:~2459757, 5-7:~2548510, 5-8:~2555440, 
5-9:~2558871
}}

\stoptext


1. Use tabular numbers and hard-code all of the spaces you need:
   \definefontfeature[default][default][tnum=yes]
   or
   \definefontfeature[ff:tnum][tnum=yes] ... \addff{ff:tnum} or
   \feature[+][ff:tnum] where appropriate.

2. Put the numbers in a table and right-align the number columns (see
   http://wiki.contextgarden.net/TABLE#Using_character_alignment if you
   need decimal alignment).

--
Rik

1. Both


=

___
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
___

[NTG-context] fixed spacing

2017-07-17 Thread Floris van Manen
dear List,

I try to put a set of numbers into a block text.
I want to keep the spacing within the items fixed
x-y:~z,
How do i do that?
The attached code does not seem to treat the fixed space as fixed.

Thanks
.Floris


\definepapersize[iiwii][width=125mm, height=125mm]
\setuppapersize[iiwii]
\setupbodyfont[7pt]
\setuplayout[backspace=3mm,
topspace=3mm,
width=70mm,
header=0mm,
footer=0mm,
height=119mm]
\starttext

\starttext
{\tfxx\framed[width=42mm,align={width,nothyphenated,verytolerant},frame=off]
{0-1:~28, 1-2:~1686, 0-2:~1710, 8-9:~3484, 7-8:~15862, 7-9:~17152, 1-3:~90632, 
0-3:~90645, 2-3:~90840, 7-6:~98762, 6-8:~100082, 6-9:~103544, 4-0:~106926, 
4-1:~106949, 4-2:~107546, 4-3:~192211, 3-6:~990165, 2-6:~1040810, 3-7:~1041891, 
1-6:~1042032, 0-6:~1042060, 3-8:~1055123, 3-9:~1057765, 2-7:~1086097, 
1-7:~1087411, 0-7:~1087439, 2-8:~1099942, 1-8:~1101249, 0-8:~1101277, 
2-9:~1102409, 1-9:~1103718, 0-9:~1103746, 4-6:~1138989, 4-7:~1180436, 
4-8:~1194617, 4-9:~1196971, 5-3:~1729640, 4-5:~1756438, 5-0:~1761922, 
5-1:~1761941, 5-2:~1763565, 5-6:~2459757, 5-7:~2548510, 5-8:~2555440, 
5-9:~2558871
}}

{\tfxx\framed[width=42mm,align={width,nothyphenated},frame=off]
{0-1:~28, 1-2:~1686, 0-2:~1710, 8-9:~3484, 7-8:~15862, 7-9:~17152, 1-3:~90632, 
0-3:~90645, 2-3:~90840, 7-6:~98762, 6-8:~100082, 6-9:~103544, 4-0:~106926, 
4-1:~106949, 4-2:~107546, 4-3:~192211, 3-6:~990165, 2-6:~1040810, 3-7:~1041891, 
1-6:~1042032, 0-6:~1042060, 3-8:~1055123, 3-9:~1057765, 2-7:~1086097, 
1-7:~1087411, 0-7:~1087439, 2-8:~1099942, 1-8:~1101249, 0-8:~1101277, 
2-9:~1102409, 1-9:~1103718, 0-9:~1103746, 4-6:~1138989, 4-7:~1180436, 
4-8:~1194617, 4-9:~1196971, 5-3:~1729640, 4-5:~1756438, 5-0:~1761922, 
5-1:~1761941, 5-2:~1763565, 5-6:~2459757, 5-7:~2548510, 5-8:~2555440, 
5-9:~2558871
}}

\stoptext



numbertest.pdf
Description: Adobe PDF document


signature.asc
Description: Message signed with OpenPGP using GPGMail
___
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
___

[NTG-context] t-vim module: math in "normal" code and background color

2017-07-17 Thread Gerion Entrup
Hi,

I have two questions with the vim module.

1. I want to use the math mode inside the code. I've seen the escape option, 
e.g. here [1], but this seems to work only with comments. Is there a 
possibility to use it directly in the code, too?

Minimal example:
```
\usemodule[vim]
\definevimtyping[python][syntax=python, escape=on]

\starttext
\startpython
# Returns \m{\sum_{i=1}^{n}i}
def sum_upto(\m{n \in \mathbb{N}})
r = range(1, \m{n} + 1)
return sum(r)
\stoppython
\stoptext
```

2. It would be cool, if I can define some background color for the code. 
Unfortunately I'm very new to context and haven't seen a direct option. I 
assume this is possible with some kind of extra environment around the code?

(I've subscribed the list, so you don't have to CC me.)

Thank you in advance,
Gerion

___
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
___

Re: [NTG-context] \xmlfirst broken?

2017-07-17 Thread Hans Hagen

On 7/17/2017 3:40 AM, Henri Menke wrote:

Dear list,

A recent question on TeX.SX is asking about XML processing.
https://tex.stackexchange.com/questions/380935

To reproduce the error from the question I copied the demo from the XML manual. 
 First of all we
have demo.xml:




   
 Some title
 
   a paragraph of text
   another paragraph of text
 
   



And then we have a ConTeXt document:


\startxmlsetups xml:demo:base
   \xmlsetsetup{#1}{*}{-}
   \xmlsetsetup{#1}{document|section|p}{xml:demo:*}
\stopxmlsetups

\xmlregisterdocumentsetup{demo}{xml:demo:base}

\startxmlsetups xml:demo:document
   \starttitle[title={Contents}]
 \placelist[chapter]
   \stoptitle
   \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:demo:section
   \startchapter[title=\xmlfirst{#1}{/title}]
 \xmlfirst{#1}{/content}
   \stopchapter
\stopxmlsetups

\startxmlsetups xml:demo:p
   \xmlflush{#1}\endgraf
\stopxmlsetups

\starttext
\xmlprocessfile{demo}{demo.xml}{}
\stoptext


This works partially.  Some entities are printed fine but stuff in \xmlfirst is 
missing.  I can
reproduce this in TL2017 and latest beta.  In the attached PDF you can see that 
the section has no
title and no content (exactly the stuff \xmlfirst was supposed to get).

just comment the line:

   \xmlsetsetup{#1}{*}{-}

or provide setups for content and title too

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
___