Re: [NTG-context] Bibliography in MKIV, custom rendering

2017-07-31 Thread Gerion Entrup
Am Montag, 31. Juli 2017, 04:23:16 CEST schrieb Gerion Entrup:
> Hi,
> 
> I need your help again. I've a bibliography and some entries references to 
> websites. Unfortunately the URL is not always rendered and the name ist 
> always 
> parsed as name of a person, not from an organisation etc.
> 
> What I want to achieve is to use the standard aps style, but with 
> additionally 
> the following two rules:
> 1. The name is always rendered without abbrevations (I guess, this is 
> authorconversion=normal).
> 2. If an URL is given, it is always rendered.
> 
> My input is a bib-file. Here is a minimal example:
> 
> input.bib
> ```
> @misc{objective-c,
> author = "Apple Inc.",
> note = "Online; accessed at 31-July-2017",
> title = "About Objective-C",
> url = 
> "https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html;,
> year = "2014"
> }
> ```
> 
> test.tex
> ```
> \usebtxdataset[default][input.bib]
> \usebtxdefinitions[aps]
> \setupbtx[default:cite][alternative=num]
> \setupbtx[default:list][authorconversion=normal]
> 
> \starttext
> According to Apple Inc., Objective-C is the main programming language, when 
> writing software for MacOS~\cite[objective-c].
> 
> \placelistofpublications
> \stoptext
> ```
> 
> I've tried to understand the manual, yout can see some of my attempts in the 
> minimal example. But I don't get really far.
> 
> Can you give me a hint?

I have "fixed" this with directly modifying the publ-imp-aps.mkvi. I guess,
this is the worst way to achive this thing, but I don't know a better one.

Here is the patch, if someone is interested.

Gerion

--- publ-imp-aps.mkvi.original  2017-07-31 21:23:14.736856430 +0200
+++ publ-imp-aps.mkvi   2017-07-31 21:24:46.860462851 +0200
@@ -58,7 +58,7 @@
 \definebtx
   [aps:\s!list]
   [aps]
-  [\c!authorconversion=normalshort]
+  [\c!authorconversion=normal]
 
 \definebtx
   [aps:\s!list:author]
@@ -1117,6 +1117,12 @@
 
 \startsetups btx:aps:list:misc
 \fastsetup{btx:aps:list:electronic}
+\btxdoif {url} {
+\btxspace
+\btxleftparenthesis
+\goto{\hyphenatedurl{\btxflush{url}}}[url(\btxflush{url})]
+\btxrightparenthesis
+}
 % Note that organization is an "ignored" field.
 \stopsetups

___
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] Couple of questions

2017-07-31 Thread Gerion Entrup
Am Montag, 31. Juli 2017, 08:01:49 CEST schrieb Jan Willem Flamma:
> Dear Gerion,
> 
> Add 
> 
> \setuphead[subsubsection]
> [incrementnumber=no]
This works :). Thank you very much!


Gerion

> > On 30 Jul 2017, at 22:51, Gerion Entrup <gerion.entrup-c...@flump.de> wrote:
> > 
> > Am Samstag, 29. Juli 2017, 11:13:21 CEST schrieb Pablo Rodriguez:
> >> On 07/29/2017 04:45 AM, Gerion Entrup wrote:
> >>> Was not that simple, but I found the problem, that causes it:
> >>> subsubsections without numbers.
> >>> [...]
> >>> Is there a way to fix this?
> >> 
> >> I would say this may be a bug.
> > Does someone know a way to workaround?
> > 
> > This only way I see is to simply simulate a subsubsection (with some blanks
> > and a big font).
> > 
> > Gerion
> > 
> > 
> >> I don’t know how it is implemented, but prefixsegments (or prefixes) for
> >> captions only work when number is enabled.
> >> 
> >> This makes sense if the section is part of the prefixsegments, but not
> >> if it isn’t.
> >> 
> >> Another sample that shows the problem:
> >> 
> >>\mainlanguage[de]
> >>\setupexternalfigures[location=default]
> >>\setuphead[subsection][number=no]
> >>\setupcaptions[prefixsegments=chapter]
> >>\setuphead[subsubsection][number=yes]
> >> 
> >>\starttext
> >> 
> >>\chapter[title=Kapitel]
> >>\placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> >> 
> >>\section[title=Abschnitt]
> >>\placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> >> 
> >>\subsection[title=Hier gibt’s ein Problem]
> >>\placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> >> 
> >>\subsection[title=Und hier gibt’s ein Problem auch]
> >>\placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> >> 
> >>\subsubsection[title=Aber hier gibt’s kein Problem]
> >>\placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> >>\stoptext
> >> 
> >> If this isn’t a bug, the code to avoid the problem is too tricky for me
> >> (and simply far beyond my knowledge).
> >> 
> >> Excuse my ignorance,
> >> 
> >> Pablo
> >> 
> > 
> > 
> > ___
> > 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
> ___


___
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] Bibliography in MKIV, custom rendering

2017-07-30 Thread Gerion Entrup
Hi,

I need your help again. I've a bibliography and some entries references to 
websites. Unfortunately the URL is not always rendered and the name ist always 
parsed as name of a person, not from an organisation etc.

What I want to achieve is to use the standard aps style, but with additionally 
the following two rules:
1. The name is always rendered without abbrevations (I guess, this is 
authorconversion=normal).
2. If an URL is given, it is always rendered.

My input is a bib-file. Here is a minimal example:

input.bib
```
@misc{objective-c,
author = "Apple Inc.",
note = "Online; accessed at 31-July-2017",
title = "About Objective-C",
url = 
"https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html;,
year = "2014"
}
```

test.tex
```
\usebtxdataset[default][input.bib]
\usebtxdefinitions[aps]
\setupbtx[default:cite][alternative=num]
\setupbtx[default:list][authorconversion=normal]

\starttext
According to Apple Inc., Objective-C is the main programming language, when 
writing software for MacOS~\cite[objective-c].

\placelistofpublications
\stoptext
```

I've tried to understand the manual, yout can see some of my attempts in the 
minimal example. But I don't get really far.

Can you give me a hint?

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] Couple of questions

2017-07-30 Thread Gerion Entrup
Am Samstag, 29. Juli 2017, 11:13:21 CEST schrieb Pablo Rodriguez:
> On 07/29/2017 04:45 AM, Gerion Entrup wrote:
> > Was not that simple, but I found the problem, that causes it:
> > subsubsections without numbers.
> > [...]
> > Is there a way to fix this?
> 
> I would say this may be a bug.
Does someone know a way to workaround?

This only way I see is to simply simulate a subsubsection (with some blanks
and a big font).

Gerion


> I don’t know how it is implemented, but prefixsegments (or prefixes) for
> captions only work when number is enabled.
> 
> This makes sense if the section is part of the prefixsegments, but not
> if it isn’t.
> 
> Another sample that shows the problem:
> 
> \mainlanguage[de]
> \setupexternalfigures[location=default]
> \setuphead[subsection][number=no]
> \setupcaptions[prefixsegments=chapter]
> \setuphead[subsubsection][number=yes]
> 
> \starttext
> 
> \chapter[title=Kapitel]
> \placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> 
> \section[title=Abschnitt]
> \placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> 
> \subsection[title=Hier gibt’s ein Problem]
> \placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> 
> \subsection[title=Und hier gibt’s ein Problem auch]
> \placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> 
> \subsubsection[title=Aber hier gibt’s kein Problem]
> \placefigure{Eine Kuh}{\externalfigure[cow.pdf][scale=250]}
> \stoptext
> 
> If this isn’t a bug, the code to avoid the problem is too tricky for me
> (and simply far beyond my knowledge).
> 
> Excuse my ignorance,
> 
> Pablo
> 


___
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] Couple of questions

2017-07-28 Thread Gerion Entrup
Am Freitag, 28. Juli 2017, 17:05:59 CEST schrieb Pablo Rodriguez:
> On 07/28/2017 02:22 AM, Gerion Entrup wrote:
> > 2. Own title format
> > I've set an own title format for chapters, like described in the wiki. 
> > Unfortunately this applies to the table of contents and bibliography as 
> > well.
> > Below a minimal example, that reproduces it:
> > ```
> > \setupinteraction[state=start]
> > 
> > \define[2]\MyChapter{\framed[frame=off,bottomframe=on,topframe=on]
> > {\vbox{\headtext{chapter} #1\blank#2}}}
> > 
> > \setuphead[chapter][command=\MyChapter, style={\switchtobodyfont[24pt,ss]}, 
> > header=empty, page=mychapterpagebreak]
> > \setupheadtext[chapter=Chapter, content=Table of Contents]
> > 
> > \starttext
> > \completecontent
> > \page[yes]
> > 
> > \startchapter[title=foo]
> > 
> > \stoptext
> > ```
> > How can I prevent the printing of "Chapter" in the table of contents and
> > bibliography?
> 
> Hi Gerion,
> 
> play with the sample, in order to see what fits you best:
> 
> \setupinteraction[state=start]
> 
> \define[2]\MyChapter{\framed[frame=off,bottomframe=on,topframe=on]
> {\vbox{\headtext{chapter} #1\blank[small]#2}}}
> 
> \setuphead[chapter][command=\MyChapter,
> style={\switchtobodyfont[24pt,ss]}, header=empty, page=mychapterpagebreak]
> 
> \startsectionblockenvironment[bodypart]
> \setupheadtext[chapter=Chapter]
> \stopsectionblockenvironment
> 
> \startsectionblockenvironment[appendix]
> \setupheadtext[chapter=Appendix]
> \stopsectionblockenvironment
> 
> \starttext
> \startfrontmatter
> \chapter{Table of Contents}\placecontent
> \stopfrontmatter
> 
> \startbodymatter
> \startchapter[title=foo]
> \stopbodymatter
> 
> \startappendices
> \chapter{Bibliography}
> \stopappendices
> 
> \startbackmatter
> \chapter{Bibliography}
> \stopbackmatter
> 
> \stoptext
Thank you, that works for me.


> > 5. Numbering of floats
> > I want a numbering for my figures in this format:
> > way=bychapter, prefixsegments=chapter
> > 
> > I guess, this is the default, but I've explicitly set it.
> > In some captions the prefix is ignored. For example there are 5 figures in 
> > chapter 2, then the captions of the figures (the text is in German) are:
> > Abbildung 2.1   foo
> > Abbildung 2.2   bar
> > Abbildung 3foobar
> > Abbildung 4otherfoo
> > Abbildung 5lastfoo
> > 
> > Is there anything, I can do, to prevent this?
> 
> I cannot reproduce the problem you mention:
> 
> \mainlanguage[de]
> \starttext
> \dorecurse{5}{\chapter{Kapitel}
> \placefigure{Eine Kuh}{\externalfigure[cow.pdf]}}
> \chapter{Kapitel}
> \dorecurse{5}{\placefigure{Eine andere Kuh}
> {\externalfigure[cow.pdf]}}
> \dorecurse{5}{\chapter{Kapitel}
> \placefigure{Noch eine andere Kuh}{\externalfigure[cow.pdf]}}
> \stoptext
> 
> In general, please provide minimal samples of code that show your problem.
Was not that simple, but I found the problem, that causes it:
subsubsections without numbers.

Here is a minimal example:
```
\mainlanguage[de]
\setuphead[subsubsection][number=off]
\setupcaptions[way=bychapter,
   prefixsegments=chapter]

\starttext

\startchapter[title=Kapitel]
\placefigure{Eine Kuh}{\externalfigure[cow.pdf]}

\startsection[title=Abschnitt]
\startsubsection[title=Unterabschnitt]
\placefigure{Eine Kuh}{\externalfigure[cow.pdf]}

\startsubsubsection[title=Und hier gibts ein Problem]
\placefigure{Eine Kuh}{\externalfigure[cow.pdf]}
\stopsubsubsection

\startsubsubsection[title=Und hier gibts ein Problem]
\stopsubsubsection

\stopsubsection
\stopsection
\stopchapter

\stoptext
```
Is there a way to fix this?

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] Couple of questions

2017-07-28 Thread Gerion Entrup
Am Freitag, 28. Juli 2017, 16:34:01 CEST schrieb Pablo Rodriguez:
> On 07/28/2017 02:22 AM, Gerion Entrup wrote:
> > [...]
> > 6. Multiple references
> > I want to create the same footnote on multiple locations in the text. 
> > Therefore I used:
> > ```
> > \setupinteraction[state=start]
> > 
> > \starttext
> > This\footnote[letter-s]{"s" is a letter.} is\note[letter-s] a 
> > nons\note[letter-s]ens\note[letter-s]e text.
> > \stoptext
> > 
> > ```
> > But this uses different fonts for the number in the text. Is there a way to 
> > fix 
> > this or do it better?
> 
> Hi Gerion,
> 
> the easiest way is to disable bold in links:
> 
> \setupinteraction[state=start, style=]
> 
> Or I guess you would have to enable bold in the footnote reference numbers.
Ah ok, then both types of references are treated different.
Your solution works, thank you.

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
___

[NTG-context] Couple of questions

2017-07-27 Thread Gerion Entrup
Hi,

this is a rather long mail, but I'll add the answers to the wiki.

For the future: Should I write one mail per question or all in one? :)

1. Color of references and table of content:
How can I define/change the colors of references and the table of content? And
why are some references red and others green?


2. Own title format
I've set an own title format for chapters, like described in the wiki. 
Unfortunately this applies to the table of contents and bibliography as well.
Below a minimal example, that reproduces it:
```
\setupinteraction[state=start]

\define[2]\MyChapter{\framed[frame=off,bottomframe=on,topframe=on]
{\vbox{\headtext{chapter} #1\blank#2}}}

\setuphead[chapter][command=\MyChapter, style={\switchtobodyfont[24pt,ss]}, 
header=empty, page=mychapterpagebreak]
\setupheadtext[chapter=Chapter, content=Table of Contents]

\starttext
\completecontent
\page[yes]

\startchapter[title=foo]

\stoptext
```
How can I prevent the printing of "Chapter" in the table of contents and
bibliography?


3. Text size in t-vim
I've defined a smaller text size in t-vim, but this seems to affect \inline... 
as well. Is there a way to circumvent this?

Minimal example:
```
\setupinteraction[state=start]

\usemodule[t-vim]
\definevimtyping[python][syntax=python,
 style={\switchtobodyfont[8pt,tt]},]
\starttext
\startpython
for line in foo:
print(line)
\stoppython
This is keyword \inlinepython{in} Python.
\stoptext
```


4. Captions of combinations
The wiki shows, how to completely autolabel figures in a combination with mkiv.
Is there a way to simply prefix the label with a), b), c),...?

Another related question: Is there a way to define the width and align of the 
labels of a combination?


5. Numbering of floats
I want a numbering for my figures in this format:
way=bychapter, prefixsegments=chapter

I guess, this is the default, but I've explicitly set it.
In some captions the prefix is ignored. For example there are 5 figures in 
chapter 2, then the captions of the figures (the text is in German) are:
Abbildung 2.1   foo
Abbildung 2.2   bar
Abbildung 3foobar
Abbildung 4otherfoo
Abbildung 5lastfoo

Is there anything, I can do, to prevent this?


6. Multiple references
I want to create the same footnote on multiple locations in the text. 
Therefore I used:
```
\setupinteraction[state=start]

\starttext
This\footnote[letter-s]{"s" is a letter.} is\note[letter-s] a 
nons\note[letter-s]ens\note[letter-s]e text.
\stoptext

```
But this uses different fonts for the number in the text. Is there a way to fix 
this or do it better?




___
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] Get number of chapter and section

2017-07-25 Thread Gerion Entrup
Hi,

I've another question. Currently I'm experimenting with the header and can 
retrieve the chapter name with \getmarkin[chapter].
How can I get the current number of the chapter (\getnumber[chapter] does not 
work) and the section?

Regards,
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] t-vim module: math in "normal" code and background color

2017-07-19 Thread Gerion Entrup
Am Mittwoch, 19. Juli 2017, 21:07:09 CEST schrieb Aditya Mahajan:
> On Wed, 19 Jul 2017, Gerion Entrup wrote:
> 
> > Am Dienstag, 18. Juli 2017, 04:04:51 CEST schrieb 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
> >> :-)
> >
> > I've invested some time and rewrote parts of the vimscript file of t-vim.
> > Now one or more escapechars can be defined, that helps vim to not interpret
> > the text:
> 
> I'll look at this later
> 
> > Another point I saw is, that highlight together with TeX-code is not really 
> > usable:
> > ```
> > \usemodule[vim]
> > \definevimtyping[python][syntax=python, escape=on]
> >
> > \starttext
> > \startpython[highlight=1]
> > # Returns \m{\sum_{i=1}^{n}i \in F \int_i f}
> > \stoppython
> > \stoptext
> > ```
> 
> By default, the highlighting is done using the bars mechanism. It works 
> for simple cases but fails with math mode (the spaces are not covered). 
> One option is to highlight using the textbackground mechanism:
> 
> \definetextbackground[texthighlight]
>  [
>background=color,
>backgroundcolor=gray,
>frame=off,
>  ]
> 
> \define[1]\texthighlight{\starttexthighlight#1\stoptexthighlight}
> 
> \usemodule[vim]
> \definevimtyping[python][syntax=python, escape=on, 
> highlightcommand=\texthighlight]
> 
> \starttext
> 
> \startpython[highlight=3]
> for x in 1:n
>print(x)
> # Returns \m{\sum_{i=1}^{n}i \in F \int_i f}
> for x in 1:n
>print(x)
> \stoppython
> \stoptext
Thank you, this works much better (critic on high level: the sum symbol is
higher than the highlight box, relevant on fractions).

 
> The spacing in math mode is bad. What is happening is the following. To 
> make sure that spaces are obeyed in the code listing, I set (a modified 
> version of) \activatespacehandler{on}, so the output that you get is the 
> following:
> 
> {\obeyspaces
>   \def\obeyedspace{\hskip\interwordspace\relax}
> \m{\sum_{i=1}^{n}i \in F \int_i f}}
> 
> The simplest way to fix this is to define a new command:
> 
> \define[1]\MATH{\bgroup\activatespacehandler{off}\m{\rescan{#1}}\egroup}
> 
> and use \MATH{} instead of \m{}.
> 
> I'll test this is a bit, and if the solution is robust, then I will map 
> \m{...} to something equivalent to the above in the t-vim environments.
I saw the strange spacing. Thank you very much to provide a solution.

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] t-vim module: math in "normal" code and background color

2017-07-18 Thread Gerion Entrup
Am Dienstag, 18. Juli 2017, 04:04:51 CEST schrieb 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 
> :-)

I've invested some time and rewrote parts of the vimscript file of t-vim.
Now one or more escapechars can be defined, that helps vim to not interpret
the text:
```
\usemodule[vim]
\definevimtyping[python][syntax=python]
\definevimtyping[cpp][syntax=cpp]

\starttext
\startpython
# Returns range(°\m{\sum_{i=1}^{n}i \in F \int_i f}°
def sum_upto(°\m{n \in \mathbb{N} \sum_{i=1}}°)
r = range(1, °\m{n}° + °\m{\sum_{i=1} 1}°)
return sum(r)
\stoppython
\startcpp
  foobar(°\m{q_0}°);
\stopcpp
\stoptext
```

I'm not familiar enough with TeX or ConTeXt to get the TeX part to work, so
the escapechar '°' is hardcoded at the moment. If you like the patch, this
has to be fixed.

Another problem, as you see in the above example, is, that vim interprets
the second ')' in the startcpp section as color code "Error", so the whole
part is colorized. This can be circumventented with the escapechars '°"', but
I have no idea how to teach tex/lua to not interpret the '"'. Simply writing
 -c "let escapechar='°\"'" %
etc. in the t-vim.tex does not work.


Another point I saw is, that highlight together with TeX-code is not really 
usable:
```
\usemodule[vim]
\definevimtyping[python][syntax=python, escape=on]

\starttext
\startpython[highlight=1]
# Returns \m{\sum_{i=1}^{n}i \in F \int_i f}
\stoppython
\stoptext
```
 
> > 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.
OK, thank you.

Gerion

From 994de513a23210f1f4d50d24270f8f988abdd21c Mon Sep 17 00:00:00 2001
From: Gerion Entrup <gerion.ent...@flump.de>
Date: Wed, 19 Jul 2017 00:13:52 +0200
Subject: [PATCH] t-vim: extended escape mode

With this change it is possible to define one or more escapechars, that
are used by vim to recognize parts that should not be interpreted.
---
 2context.vim | 50 +-
 t-vim.tex| 12 ++--
 2 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/2context.vim b/2context.vim
index 9c72ba1..b208e65 100644
--- a/2context.vim
+++ b/2context.vim
@@ -8,6 +8,11 @@
 " output buffer. The script parses content line-by-line from the first buffer
 " and pastes the modified result on the second buffer.
 
+" Compare a char of  at  with some Unicode 
+function UnicodeCompare(string, bytepos, ochar)
+return strpart(a:string, a:bytepos, max([strlen(a:ochar), 1])) ==# a:ochar
+endfunction
+
 " Split screen and go to the second buffer, ensure modifiable is set, and the
 " buffer is empty.
 sblast 
@@ -38,9 +43,9 @@ if !exists("highlight")
   let highlight=[]
 endif
 
-" Set escapecomments
-if !exists("escapecomments")
-  let escapecomments=0
+" Set escapechar
+if !exists("escapechar")
+  let escapechar=''
 endif
 
 let s:strip = strlen( matchstr( getline(s:lstart), '^\s*' ) )
@@ -71,37 +76,48 @@ let s:lines = []
 let s:buffer_lnum = 1
 let s:lnum = s:lstart
 
+let s:lenesc = strlen(escapechar)
+
 while s:lnum <= s:lstop

[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] TikZ module not found (TeX Live problem?)

2017-06-21 Thread Gerion Entrup
Am Dienstag, 20. Juni 2017, 16:15:59 CEST schrieb Gerion Entrup:
> Am Dienstag, 20. Juni 2017, 13:25:42 CEST schrieb Gerion Entrup:
> > Am Dienstag, 20. Juni 2017, 11:45:19 CEST schrieb Henri Menke:
> > > On Mon, 2017-06-19 at 02:34 +0200, Gerion Entrup wrote:
> > > > Good day,
> > > > 
> > > > I'm very new to ConTeXt, so maybe this is a fairly simple question.
> > > > 
> > > > I want to use TikZ in the document. The specific part of the document 
> > > > is:
> > > >  snip 
> > > > \usemodule[tikz]
> > > > \usetikzlibrary[positioning]
> > > >  /snip -
> > > > 
> > > > The problem seems to be that ConTeXt does not find the TikZ module. I 
> > > > use mkiv. The relevant
> > > > output:
> > > >  snip -
> > > > % context test-document.tex
> > > > 
> > > > mtx-context | run 1: luatex 
> > > > --fmt="/home/gerion/.texlive/texmf-var/luatex-
> > > > cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en" 
> > > > --jobname="test-document"
> > > > --lua="/home/gerion/.texlive/texmf-var/luatex-
> > > > cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en.lui"
> > > >  --no-parse-first-line
> > > > --c:currentrun=1 --c:fulljobname="./test-document.tex" 
> > > > --c:input="./test-document.tex" --
> > > > c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
> > > > This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
> > > >  system commands enabled.
> > > > open source > 1 > 1 > 
> > > > /usr/share/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv
> > > > 
> > > > ConTeXt  ver: 2016.05.17 19:20 MKIV current  fmt: 2017.6.11  int: 
> > > > english/english
> > > > 
> > > > system  > 'cont-new.mkiv' loaded
> > > > open source > 2 > 2 > 
> > > > /usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
> > > > close source> 2 > 2 > 
> > > > /usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
> > > > system  > files > jobname 'test-document', input 
> > > > './test-document', result 'test-document'
> > > > fonts   > latin modern fonts are not preloaded
> > > > languages   > language 'en' is active
> > > > open source > 2 > 3 > 
> > > > /home/gerion/sourcecode/grisu/test-document/test-document.tex
> > > > colors  > 'rgb' color space is supported
> > > > colors  > 'cmyk' color space is supported
> > > > resolvers   > modules > 'tikz' is not found
> > > > 
> > > > tex error   > tex error on line 6 in file 
> > > > /home/gerion/sourcecode/test-document/test-
> > > > document.tex: ! Undefined control sequence
> > > > 
> > > >  \usetikzlibrary 
> > > > 
> > > > l.6 \usetikzlibrary
> > > >  [positioning]
> > > > 
> > > >  1 \mainlanguage[de]
> > > >  2 
> > > >  3 \setupcolors[state=start]
> > > >  4 
> > > >  5 \usemodule[tikz]
> > > >  6 >>  \usetikzlibrary[positioning]
> > > >  7
> > > > - /snip -
> > > > 
> > > > Using TikZ within LaTeX is no problem in this distribution. Is this a 
> > > > problem of TeX Live (or the
> > > > distribution packaging)?
> > > > I've looked in the installed files of texlive-context and other modules 
> > > > are installed, even
> > > > modules that require TikZ (eg. gantt).
> > > 
> > > With TL 2017 the following example works as without problems.  Post a 
> > > minimal example to reproduce
> > > your problem, otherwise we can't help you.  Also, your problem suggests a 
> > > faulty TL installation.
> > > 
> > > \usemodule[tikz]
> > > \usetikzlibrary[positioning]
> > > 
> > > \starttext
> > > 
> > > \tikz\node{Hello World!};
> > > 
> > > \stoptext
> > Thanks so far. This exact example leads to the same error:
> > --- snip --
> > % context test.tex
> > 
> > mtx-context | run 1: luatex 
> > --fmt="/home/gerion/.tex

Re: [NTG-context] TikZ module not found (TeX Live problem?)

2017-06-20 Thread Gerion Entrup
Am Dienstag, 20. Juni 2017, 13:25:42 CEST schrieb Gerion Entrup:
> Am Dienstag, 20. Juni 2017, 11:45:19 CEST schrieb Henri Menke:
> > On Mon, 2017-06-19 at 02:34 +0200, Gerion Entrup wrote:
> > > Good day,
> > > 
> > > I'm very new to ConTeXt, so maybe this is a fairly simple question.
> > > 
> > > I want to use TikZ in the document. The specific part of the document is:
> > >  snip 
> > > \usemodule[tikz]
> > > \usetikzlibrary[positioning]
> > >  /snip -
> > > 
> > > The problem seems to be that ConTeXt does not find the TikZ module. I use 
> > > mkiv. The relevant
> > > output:
> > >  snip -
> > > % context test-document.tex
> > > 
> > > mtx-context | run 1: luatex 
> > > --fmt="/home/gerion/.texlive/texmf-var/luatex-
> > > cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en" 
> > > --jobname="test-document"
> > > --lua="/home/gerion/.texlive/texmf-var/luatex-
> > > cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en.lui"
> > >  --no-parse-first-line
> > > --c:currentrun=1 --c:fulljobname="./test-document.tex" 
> > > --c:input="./test-document.tex" --
> > > c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
> > > This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
> > >  system commands enabled.
> > > open source > 1 > 1 > 
> > > /usr/share/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv
> > > 
> > > ConTeXt  ver: 2016.05.17 19:20 MKIV current  fmt: 2017.6.11  int: 
> > > english/english
> > > 
> > > system  > 'cont-new.mkiv' loaded
> > > open source > 2 > 2 > 
> > > /usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
> > > close source> 2 > 2 > 
> > > /usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
> > > system  > files > jobname 'test-document', input 
> > > './test-document', result 'test-document'
> > > fonts   > latin modern fonts are not preloaded
> > > languages   > language 'en' is active
> > > open source > 2 > 3 > 
> > > /home/gerion/sourcecode/grisu/test-document/test-document.tex
> > > colors  > 'rgb' color space is supported
> > > colors  > 'cmyk' color space is supported
> > > resolvers   > modules > 'tikz' is not found
> > > 
> > > tex error   > tex error on line 6 in file 
> > > /home/gerion/sourcecode/test-document/test-
> > > document.tex: ! Undefined control sequence
> > > 
> > >  \usetikzlibrary 
> > > 
> > > l.6 \usetikzlibrary
> > >  [positioning]
> > > 
> > >  1 \mainlanguage[de]
> > >  2 
> > >  3 \setupcolors[state=start]
> > >  4 
> > >  5 \usemodule[tikz]
> > >  6 >>  \usetikzlibrary[positioning]
> > >  7
> > > - /snip -
> > > 
> > > Using TikZ within LaTeX is no problem in this distribution. Is this a 
> > > problem of TeX Live (or the
> > > distribution packaging)?
> > > I've looked in the installed files of texlive-context and other modules 
> > > are installed, even
> > > modules that require TikZ (eg. gantt).
> > 
> > With TL 2017 the following example works as without problems.  Post a 
> > minimal example to reproduce
> > your problem, otherwise we can't help you.  Also, your problem suggests a 
> > faulty TL installation.
> > 
> > \usemodule[tikz]
> > \usetikzlibrary[positioning]
> > 
> > \starttext
> > 
> > \tikz\node{Hello World!};
> > 
> > \stoptext
> Thanks so far. This exact example leads to the same error:
> --- snip --
> % context test.tex
> 
> mtx-context | run 1: luatex 
> --fmt="/home/gerion/.texlive/texmf-var/luatex-cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en"
>  --jobname="test" 
> --lua="/home/gerion/.texlive/texmf-var/luatex-cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en.lui"
>  --no-parse-first-line --c:currentrun=1 --c:fulljobname="./test.tex" 
> --c:input="./test.tex" --c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
> This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
>  system commands enabled.
> open source > 1 

Re: [NTG-context] TikZ module not found (TeX Live problem?)

2017-06-20 Thread Gerion Entrup
Am Dienstag, 20. Juni 2017, 11:45:19 CEST schrieb Henri Menke:
> On Mon, 2017-06-19 at 02:34 +0200, Gerion Entrup wrote:
> > Good day,
> > 
> > I'm very new to ConTeXt, so maybe this is a fairly simple question.
> > 
> > I want to use TikZ in the document. The specific part of the document is:
> >  snip 
> > \usemodule[tikz]
> > \usetikzlibrary[positioning]
> >  /snip -
> > 
> > The problem seems to be that ConTeXt does not find the TikZ module. I use 
> > mkiv. The relevant
> > output:
> >  snip -
> > % context test-document.tex
> > 
> > mtx-context | run 1: luatex 
> > --fmt="/home/gerion/.texlive/texmf-var/luatex-
> > cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en" 
> > --jobname="test-document"
> > --lua="/home/gerion/.texlive/texmf-var/luatex-
> > cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en.lui" 
> > --no-parse-first-line
> > --c:currentrun=1 --c:fulljobname="./test-document.tex" 
> > --c:input="./test-document.tex" --
> > c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
> > This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
> >  system commands enabled.
> > open source > 1 > 1 > 
> > /usr/share/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv
> > 
> > ConTeXt  ver: 2016.05.17 19:20 MKIV current  fmt: 2017.6.11  int: 
> > english/english
> > 
> > system  > 'cont-new.mkiv' loaded
> > open source > 2 > 2 > 
> > /usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
> > close source> 2 > 2 > 
> > /usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
> > system  > files > jobname 'test-document', input './test-document', 
> > result 'test-document'
> > fonts   > latin modern fonts are not preloaded
> > languages   > language 'en' is active
> > open source > 2 > 3 > 
> > /home/gerion/sourcecode/grisu/test-document/test-document.tex
> > colors  > 'rgb' color space is supported
> > colors  > 'cmyk' color space is supported
> > resolvers   > modules > 'tikz' is not found
> > 
> > tex error   > tex error on line 6 in file 
> > /home/gerion/sourcecode/test-document/test-
> > document.tex: ! Undefined control sequence
> > 
> >  \usetikzlibrary 
> > 
> > l.6 \usetikzlibrary
> >  [positioning]
> > 
> >  1 \mainlanguage[de]
> >  2 
> >  3 \setupcolors[state=start]
> >  4 
> >  5 \usemodule[tikz]
> >  6 >>  \usetikzlibrary[positioning]
> >  7
> > - /snip -
> > 
> > Using TikZ within LaTeX is no problem in this distribution. Is this a 
> > problem of TeX Live (or the
> > distribution packaging)?
> > I've looked in the installed files of texlive-context and other modules are 
> > installed, even
> > modules that require TikZ (eg. gantt).
> 
> With TL 2017 the following example works as without problems.  Post a minimal 
> example to reproduce
> your problem, otherwise we can't help you.  Also, your problem suggests a 
> faulty TL installation.
> 
> \usemodule[tikz]
> \usetikzlibrary[positioning]
> 
> \starttext
> 
> \tikz\node{Hello World!};
> 
> \stoptext
Thanks so far. This exact example leads to the same error:
--- snip --
% context test.tex

mtx-context | run 1: luatex 
--fmt="/home/gerion/.texlive/texmf-var/luatex-cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en"
 --jobname="test" 
--lua="/home/gerion/.texlive/texmf-var/luatex-cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en.lui"
 --no-parse-first-line --c:currentrun=1 --c:fulljobname="./test.tex" 
--c:input="./test.tex" --c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
 system commands enabled.
open source > 1 > 1 > 
/usr/share/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv

ConTeXt  ver: 2016.05.17 19:20 MKIV current  fmt: 2017.6.11  int: 
english/english

system  > 'cont-new.mkiv' loaded
open source > 2 > 2 > 
/usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
close source> 2 > 2 > 
/usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
system  > files > jobname 'test', input './test', result 'test'
fonts   > latin modern fonts are not preloaded
languages   > language 'en' is active

[NTG-context] TikZ module not found (TeX Live problem?)

2017-06-20 Thread Gerion Entrup
Good day,

I'm very new to ConTeXt, so maybe this is a fairly simple question.

I want to use TikZ in the document. The specific part of the document is:
 snip 
\usemodule[tikz]
\usetikzlibrary[positioning]
 /snip -

The problem seems to be that ConTeXt does not find the TikZ module. I use mkiv. 
The relevant output:
 snip -
% context test-document.tex

mtx-context | run 1: luatex 
--fmt="/home/gerion/.texlive/texmf-var/luatex-cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en"
 --jobname="test-document" 
--lua="/home/gerion/.texlive/texmf-var/luatex-cache/context/0399a8df3aef8d154781d0a9c2b8e28d/formats/luatex/cont-en.lui"
 --no-parse-first-line --c:currentrun=1 --c:fulljobname="./test-document.tex" 
--c:input="./test-document.tex" --c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
 system commands enabled.
open source > 1 > 1 > 
/usr/share/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv

ConTeXt  ver: 2016.05.17 19:20 MKIV current  fmt: 2017.6.11  int: 
english/english

system  > 'cont-new.mkiv' loaded
open source > 2 > 2 > 
/usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
close source> 2 > 2 > 
/usr/share/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
system  > files > jobname 'test-document', input './test-document', 
result 'test-document'
fonts   > latin modern fonts are not preloaded
languages   > language 'en' is active
open source > 2 > 3 > 
/home/gerion/sourcecode/grisu/test-document/test-document.tex
colors  > 'rgb' color space is supported
colors  > 'cmyk' color space is supported
resolvers   > modules > 'tikz' is not found

tex error   > tex error on line 6 in file 
/home/gerion/sourcecode/test-document/test-document.tex: ! Undefined control 
sequence

 \usetikzlibrary 

l.6 \usetikzlibrary
 [positioning]

 1 \mainlanguage[de]
 2 
 3 \setupcolors[state=start]
 4 
 5 \usemodule[tikz]
 6 >>  \usetikzlibrary[positioning]
 7
- /snip -

Using TikZ within LaTeX is no problem in this distribution. Is this a problem 
of TeX Live (or the distribution packaging)?
I've looked in the installed files of texlive-context and other modules are 
installed, even modules that require TikZ (eg. gantt).

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