[NTG-context] macro string in metapost

2011-11-01 Thread Meer, H. van der
The goal is to make the following string in metapost:
  string s; where s must become "\MPcolor{Blue}".
and ultimately execute this at the right moment with: scantokens s;

The following makes s = "MPcolor{Blue}":
  s := "MPcolor" & char oct"134" & char oct"173" & "Blue" & char oct"134" & 
char oct"175";

But I seem unable to add a \ in front of it without expanding the string by 
TeX. Thus it does not work to put:
  s := char oct"134" & "MPcolor" & char oct"134" & char oct"173" & "Blue" & 
char oct"134" & char oct"175";

Placing a \noexpand in front does not help.

How to?

Hans van der Meer



___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] ConvertToConteXt 0.2 - convert special ConTeXt-characters (PHP)

2011-11-01 Thread Philipp Gesang
On 2011-11-01 20:16, Jan Heinen wrote:
> @all: of course not every Character, i am converting, is a
> ConTeXt-special-character. Though I don't know all important
> characters I took all I could imagine. Shurly I converted
> too much however it is no problem:

> Which character must not be converted?

··· from catc-ctx.mkiv ··

\startcatcodetable \ctxcatcodes
\catcode\tabasciicode   \spacecatcode
\catcode\endoflineasciicode \endoflinecatcode
\catcode\formfeedasciicode  \endoflinecatcode
\catcode\spaceasciicode \spacecatcode
\catcode\endoffileasciicode \ignorecatcode
  % \catcode\circumflexasciicode\superscriptcatcode
  % \catcode\underscoreasciicode\subscriptcatcode
  % \catcode\ampersandasciicode \alignmentcatcode
\catcode\underscoreasciicode\othercatcode
\catcode\circumflexasciicode\othercatcode
\catcode\ampersandasciicode \othercatcode
\catcode\backslashasciicode \escapecatcode
\catcode\leftbraceasciicode \begingroupcatcode
\catcode\rightbraceasciicode\endgroupcatcode
\catcode\dollarasciicode\mathshiftcatcode
\catcode\hashasciicode  \parametercatcode
\catcode\commentasciicode   \commentcatcode
\catcode\tildeasciicode \activecatcode
\catcode\barasciicode   \activecatcode
\stopcatcodetable

·

So, afaict, assuming standard catcodes you should be safe with
escaping »~|\{}$%#« (of which the bar was missing in the snippet
I posted).

Good luck,
Philipp


> 
> I had a mistake in the function, below is the next version:
> 
> Regards, Janis
> 
> function ConvertToConteXt ( $xstring ) {
> /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * * *
>  * ConvertToConteXt()
>  * Version 0.2
>  * 01.11.2011
>  *
>  *  author: Jörg Kopp
>  *  www.dr-kopp.com
>  *
>  *  Convert special ConTeXt-characters with php
>  *  Works with PHP5
>  *
>  *  Call it with the string you want to convert ...
>  * ConvertToConteXt ($xstring);
>  *
>  *  ... and you get back the converted string
>  *
>  *  e.g.:
>  *  Input:
>  *  $string = "My root-Directory: /home/hans";
>  *  $string = ConvertToConteXt ( $string );
>  *
>  *  Output/Return:
>  *  $string = "My root\\char45Directory\\char58
> \\char47home\\char47hans";
>  *
>  *  When you write this into a file ...
>  *  file_put_contents ( "example.tex", "My
> root\\char45Directory\char58 \\char47home\\char47hans", FILE_APPEND
> );
>  *
>  *  ... You will find the following in example.tex:
>  *  My root\char45Directory\char58 \char47home\char47hans
>  *
>  *  An when you compile example.tex with ConTeXt
>  *  context example.text
>  *
>  *  You can read the following in the resulting example.pdf:
>  *  My root-Directory: /home/hans
>  *
>  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * */
> 
>   $xstring = html_entity_decode ( $xstring );// convert
> HTML-entities into normal characters
> 
>   // Braces and Backslash need to be handled first otherwise trash
> will be produced
>   $xstring = str_replace ( "{",  "*$##char123##$*", $xstring );
> // geschweifte Klammer auf/left curly brace
>   $xstring = str_replace ( "}",  "*$##char125##$*", $xstring );
> // geschweifte Klammer zu/right curly brace
>   $xstring = str_replace ( "\\", "{\\char92}",  $xstring );
> // Backslash/backslash
>   $xstring = str_replace ( "*$##char123##$*",  "{\\char123}",
> $xstring ); // This trick is nessecary ...
>   $xstring = str_replace ( "*$##char125##$*",  "{\\char125}",
> $xstring ); // ...  !!!
> 
>   $xstring = str_replace ( "!",  "{\\char33}",  $xstring ); //
> Ausrufungszeichen/ConvertToConteXt
>   $xstring = str_replace ( "\"", "{\\char34}",  $xstring ); //
> Anführungszeichen/quotation mark
>   $xstring = str_replace ( "#",  "{\\char35}",  $xstring ); //
> Raute/number sign
>   $xstring = str_replace ( "$",  "{\\char36}",  $xstring ); //
> Dollar-Zeichen/dollar sign
>   $xstring = str_replace ( "%",  "{\\char37}",  $xstring ); //
> Prozent-Zeichen/percent sign
>   $xstring = str_replace ( "&",  "{\\char38}",  $xstring ); //
> Kaufmännisches Und/ampersand
>   $xstring = str_replace ( "'",  "{\\char39}",  $xstring ); //
> Apostroph/apostrophe
>   $xstring = str_replace ( "(",  "{\\char40}",  $xstring ); //
> Klammer auf/left parenthesis
>   $xstring = str_replace ( ")",  "{\\char41}",  $xstring ); //
> Klammer zu/right parenthesis
>   $xstring = str_replace ( "*",  "{\\char42}",  $xstring ); //
> Stern/asterisk
>   $xstring = str_replace ( "+",  "{\\char43}",  $xstring ); //
> Plus/plus sign
>   $xstring = str_replace ( ",",  "{\\char44}",  $xstring ); //
> Komma/comma
>   $xstring = str_replace ( "-",  "{\\char45}",  $xstring ); //
> Minus/hyphen
>   $xstring = str_replace ( ".",  "{\\char46}",  $xstrin

Re: [NTG-context] reference bug: MkiV

2011-11-01 Thread Wolfgang Schuster

Am 01.11.2011 um 20:20 schrieb Idris Samawi Hamid ادريس سماوي حامد:

> On Tue, 01 Nov 2011 12:59:41 -0600, Wolfgang Schuster 
>  wrote:
> 
> 
>>> The reference is not generated in either method:
>>> 
>>> ===log==
>>> check   > missing or ungrouped '=' after 'ref' in line 2 
>>> (@@mcinoutermargin:)
>>> references  > unknown reference [][ref]
>>> references  > unknown reference [][reff]
>>> 
>>> 
>>> Please advise and
>> 
>> \inoutermargin doesn’t support references and the optional argument expects 
>> a assignments as you can see from the message
> 
> Well, that's quite frustrating... I have a 400-page document I'm trying to 
> port to MkIV full of references, the old \inmargin no longer respect 
> [align=outer], so I switched to the new system, and now the new system does 
> not support references …

The old \inmargin command is gone, Hans rewrote the whole code for \inmargin 
etc.

You can change the alignment global with \setupmarginframed[align=outer] for 
for a single
command with \inmargin[][align=outer]{…}

> Is there any workaround, either for \inmargin or \inoutermargin? My publisher 
> is going to kill me ;-)

\usemodule[annotation]

%\defineannotation[mymargin][alternative=inmargin]

\define[2]\MymarginCommand
  {\inmargin[scope=local]{#2}}

\defineannotation
  [mymargin]
  [alternative=command,
   command=\MymarginCommand]

\starttext

See is a test.\mymargin[reference=mar:test]{Test}

See \at{page}[mar:test].

\stoptext

Wolfgang
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] reference bug: MkiV

2011-11-01 Thread Idris Samawi Hamid ادريس سماوي حامد
On Tue, 01 Nov 2011 12:59:41 -0600, Wolfgang Schuster  
 wrote:




The reference is not generated in either method:

===log==
check   > missing or ungrouped '=' after 'ref' in line 2  
(@@mcinoutermargin:)

references  > unknown reference [][ref]
references  > unknown reference [][reff]


Please advise and


\inoutermargin doesn’t support references and the optional argument  
expects a assignments as you can see from the message


Well, that's quite frustrating... I have a 400-page document I'm trying to  
port to MkIV full of references, the old \inmargin no longer respect  
[align=outer], so I switched to the new system, and now the new system  
does not support references ...


Is there any workaround, either for \inmargin or \inoutermargin? My  
publisher is going to kill me ;-)


Best wishes
Idris
--
Professor Idris Samawi Hamid, Editor-in-Chief
International Journal of Shīʿī Studies
Department of Philosophy
Colorado State University
Fort Collins, CO 80523
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] ConvertToConteXt 0.2 - convert special ConTeXt-characters (PHP)

2011-11-01 Thread Jan Heinen

At first: I am ConTeXt-newby and know PHP very well.

@Peter Münster/Aditya Mahajan  : I think \startasci and 
\stopasci is not the solution, when you generate 
ConTeXt-code with php full of ConTeXt-macro-calls:
because sometimes the special-characters are 
ConTeXt-special-characters and sometimes they are purely the 
wanted text.
@Philipp Gesang: I think Luatex could do the same job for me 
as PHP - however I am familar with PHP.
@all: of course not every Character, i am converting, is a 
ConTeXt-special-character. Though I don't know all important 
characters I took all I could imagine. Shurly I converted

too much however it is no problem:
I have tested my function "ConvertToConteXt" with 400 Pages 
full of text and lots of ConTeXt-special-characters and 
ConTeXt-macro-calls and compiled a nice book with ConText.


Which character must not be converted?

I had a mistake in the function, below is the next version:

Regards, Janis

function ConvertToConteXt ( $xstring ) {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* * * * * * * * *

 * ConvertToConteXt()
 * Version 0.2
 * 01.11.2011
 *
 *  author: Jörg Kopp
 *  www.dr-kopp.com
 *
 *  Convert special ConTeXt-characters with php
 *  Works with PHP5
 *
 *  Call it with the string you want to convert ...
 * ConvertToConteXt ($xstring);
 *
 *  ... and you get back the converted string
 *
 *  e.g.:
 *  Input:
 *  $string = "My root-Directory: /home/hans";
 *  $string = ConvertToConteXt ( $string );
 *
 *  Output/Return:
 *  $string = "My root\\char45Directory\\char58 
\\char47home\\char47hans";

 *
 *  When you write this into a file ...
 *  file_put_contents ( "example.tex", "My 
root\\char45Directory\char58 \\char47home\\char47hans", 
FILE_APPEND );

 *
 *  ... You will find the following in example.tex:
 *  My root\char45Directory\char58 
\char47home\char47hans

 *
 *  An when you compile example.tex with ConTeXt
 *  context example.text
 *
 *  You can read the following in the resulting 
example.pdf:

 *  My root-Directory: /home/hans
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* * * * * * * * */


  $xstring = html_entity_decode ( $xstring );// 
convert HTML-entities into normal characters


  // Braces and Backslash need to be handled first 
otherwise trash will be produced
  $xstring = str_replace ( "{",  "*$##char123##$*", 
$xstring );   // geschweifte Klammer auf/left 
curly brace
  $xstring = str_replace ( "}",  "*$##char125##$*", 
$xstring );   // geschweifte Klammer zu/right 
curly brace
  $xstring = str_replace ( "\\", "{\\char92}",  $xstring ); 
// Backslash/backslash
  $xstring = str_replace ( "*$##char123##$*",  
"{\\char123}", $xstring ); // This trick is nessecary ...
  $xstring = str_replace ( "*$##char125##$*",  
"{\\char125}", $xstring ); // ...  !!!


  $xstring = str_replace ( "!",  "{\\char33}",  $xstring ); 
// Ausrufungszeichen/ConvertToConteXt
  $xstring = str_replace ( "\"", "{\\char34}",  $xstring ); 
// Anführungszeichen/quotation mark
  $xstring = str_replace ( "#",  "{\\char35}",  $xstring ); 
// Raute/number sign
  $xstring = str_replace ( "$",  "{\\char36}",  $xstring ); 
// Dollar-Zeichen/dollar sign
  $xstring = str_replace ( "%",  "{\\char37}",  $xstring ); 
// Prozent-Zeichen/percent sign
  $xstring = str_replace ( "&",  "{\\char38}",  $xstring ); 
// Kaufmännisches Und/ampersand
  $xstring = str_replace ( "'",  "{\\char39}",  $xstring ); 
// Apostroph/apostrophe
  $xstring = str_replace ( "(",  "{\\char40}",  $xstring ); 
// Klammer auf/left parenthesis
  $xstring = str_replace ( ")",  "{\\char41}",  $xstring ); 
// Klammer zu/right parenthesis
  $xstring = str_replace ( "*",  "{\\char42}",  $xstring ); 
// Stern/asterisk
  $xstring = str_replace ( "+",  "{\\char43}",  $xstring ); 
// Plus/plus sign
  $xstring = str_replace ( ",",  "{\\char44}",  $xstring ); 
// Komma/comma
  $xstring = str_replace ( "-",  "{\\char45}",  $xstring ); 
// Minus/hyphen
  $xstring = str_replace ( ".",  "{\\char46}",  $xstring ); 
// Punkt/period
  $xstring = str_replace ( "/",  "{\\char47}",  $xstring ); 
// Schrägstrich/period
  $xstring = str_replace ( ":",  "{\\char58}",  $xstring ); 
// Doppelpunkt/colon
  $xstring = str_replace ( ";",  "{\\char59}",  $xstring ); 
// Semikolon/semicolon
  $xstring = str_replace ( "<",  "{\\char60}",  $xstring ); 
// Kleinerzeichen/less-than
  $xstring = str_replace ( "=",  "{\\char61}",  $xstring ); 
// Gleichzeichen/equals-to
  $xstring = str_replace ( ">",  "{\\char62}",  $xstring ); 
// Größerzeichen/greater-than
  $xstring = str_replace ( "?",  "{\\char63}",  $xstring ); 
// Fragezeichen/question mark
  $xstring = str_replace ( "@",  "{\\char64}",  $xstring ); 
// at-Zeichen/at sign
  $xstring = str_replace ( "[",  "{\\char91}",  $xstring ); 
// eckige Klammer auf/left sq

Re: [NTG-context] reference bug: MkiV

2011-11-01 Thread Wolfgang Schuster

Am 01.11.2011 um 19:47 schrieb Idris Samawi Hamid ادريس سماوي حامد:

> Dear cabal,
> 
> There seems to be a bug in MkIV:
> 
> 
> \starttext
> This is a test \inoutermargin[ref]{test}
> 
> As explained earlier (page \at[ref])
> 
> This is a test \inoutermargin[reference=reff]{test}
> 
> As explained earlier (page \at[reff])
> \stoptext
> 
> 
> The reference is not generated in either method:
> 
> ===log==
> check   > missing or ungrouped '=' after 'ref' in line 2 
> (@@mcinoutermargin:)
> references  > unknown reference [][ref]
> references  > unknown reference [][reff]
> 
> 
> Please advise and

\inoutermargin doesn’t support references and the optional argument expects a 
assignments as you can see from the message

Wolfgang
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] reference bug: MkiV

2011-11-01 Thread Idris Samawi Hamid ادريس سماوي حامد

Dear cabal,

There seems to be a bug in MkIV:


\starttext
This is a test \inoutermargin[ref]{test}

As explained earlier (page \at[ref])

This is a test \inoutermargin[reference=reff]{test}

As explained earlier (page \at[reff])
\stoptext


The reference is not generated in either method:

===log==
check   > missing or ungrouped '=' after 'ref' in line 2  
(@@mcinoutermargin:)

references  > unknown reference [][ref]
references  > unknown reference [][reff]


Please advise and

Best wishes
Idris
--
Professor Idris Samawi Hamid, Editor-in-Chief
International Journal of Shīʿī Studies
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

reference.tex
Description: TeX document
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] ConvertToConteXt - convert special ConTeXt-characters (PHP)

2011-11-01 Thread Philipp Gesang
Good evening, Jannis!

On 2011-11-01 17:16, Jan Heinen wrote:
> Today I wrote the function "ConvertToConteXt" which converts special
> ConTeXt-characters. You can see it below.

The data necessary for converting HTML entities is already in
Context, have a look at “char-ent.lua” if you are interested.
Based on this you could write the deentitizer (== your
“html_entity_decode” function?) + character handler in “pure”
Context (no PHP needed) as follows:

··· deent.cld ···

thirddata = thirddata or { }
thirddata.myfunctions = thirddata.myfunctions or { }
local myfunctions = thirddata.myfunctions

local entities = characters.entities
local utf8byte = unicode.utf8.byte

local lpegmatch= lpeg.match
local P, R, S, Cs  = lpeg.P, lpeg.R, lpeg.S, lpeg.Cs

local fmt, stringupper = string.format, string.upper

do
  local s_hex = [[{\char"%s}]]
  local s_dec = [[{\char%s}]]
  local replace_hex_entity = function (hexnum)
return fmt(s_hex, stringupper(hexnum))
  end
  local replace_dec_entity = function (decimal)
return fmt(s_dec, decimal)
  end
  local replace_named_entity = function (name)
return fmt(s_dec, utf8byte(entities[name]))
  end
  local replace_unsafe = function (char)
return fmt(s_dec, utf8byte(char))
  end
  --local backslash  = P[[\]]
  --local escaped= backslash / "" * 1
  local semicolon  = P";"
  local ucase_letter   = R"AZ"
  local lcase_letter   = R"az"
  local decimal_digit  = R"09"
  local decimal_number = decimal_digit^1
  local hex_digit  = decimal_digit + R"AF" + R"af"
  local hex_number = hex_digit^1
  local entity_char= ucase_letter + lcase_letter + decimal_digit
  local entity_chars   = entity_char^1
  local entity = (P"&#x" / "") * (hex_number / replace_hex_entity)  
 * (semicolon / "")
   + (P"&#"  / "") * (decimal_number / replace_dec_entity)  
 * (semicolon / "")
   + (P"&"   / "") * (entity_chars   / 
replace_named_entity) * (semicolon / "")
  local unsafe = S[[{}\$~%]] / replace_unsafe
  --local p_characters   = Cs((escaped + unsafe + entity + 1)^0)
  local p_characters   = Cs((unsafe + entity + 1)^0)

  myfunctions.convert_to_context = function (str)
return lpegmatch(p_characters, str)
  end
end

--- Testing ...

local someinput = [[
a º b • c ° d
B e Ł f } g } h
&non-well-formed; i { j
} k { l \ m $ n + o - p ^ q _ r @ s ` t ~ u ! v % w
« x
]]

context.starttext()
context(myfunctions.convert_to_context(someinput))
context.stoptext()

·

> 3. Did I forget to convert a character?

Most of the chars you substituted have no special semantics in
the first place.

Philipp


> Before I put it into contextgarden.net ...
> 1. ... please test it.
> 2. You see three characters, where I don't know the code-number
> \char??? for ConTeXt. Do you know them?
> 3. Did I forget to convert a character?
> 
> Regards
> Jannis
> 
> 
> 
> function ConvertToConteXt ( $xstring ) {
> /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * * *
>  *
>  *  author: Jörg Kopp
>  *  www.dr-kopp.com
>  *  01.11.2011
>  *
>  *  Convert special ConTeXt-characters with php
>  *  Works with PHP5
>  *
>  *  Call it with the string you want to convert ...
>  * ConvertToConteXt ($xstring);
>  *
>  *  ... and you get back the converted string
>  *
>  *  e.g.:
>  *  Input:
>  *  $string = "My root-Directory: /home/hans";
>  *  $string = ConvertToConteXt ( $string );
>  *
>  *  Output/Return:
>  *  $string = "My root\\char45Directory\\char58
> \\char47home\\char47hans";
>  *
>  *  When you write this into a file ...
>  *  file_put_contents ( "example.tex", "My
> root\\char45Directory\char58 \\char47home\\char47hans", FILE_APPEND
> );
>  *
>  *  ... You will find the following in example.tex:
>  *  My root\char45Directory\char58 \char47home\char47hans
>  *
>  *  An when you compile example.tex with ConTeXt
>  *  context example.text
>  *
>  *  You can read the following in the resulting example.pdf:
>  *  My root-Directory: /home/hans
>  *
>  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * * * */
> 
>   $xstring = html_entity_decode ( $xstring ); // convert
> HTML-entities into normal characters
>   $xstring = str_replace ( "!",  "\\char33",  $xstring ); //
> Ausrufungszeichen/ConvertToConteXt
>   $xstring = str_replace ( "\"", "\\char34",  $xstring ); //
> Anführungszeichen/quotation mark
>   $xstring = str_replace ( "#",  "\\char35",  $xstring ); //
> Raute/number sign
>   $xstring = str_replace ( "$",  "\\char36",  $xstring ); //
> Dollar-Zeichen/dollar sign
>   $xstring = str_replace ( "%",  "\\char37",  $xstring ); //
> Prozent-Zeichen/percent sign
>   $xstring = str_replace ( "&",  "

Re: [NTG-context] ConvertToConteXt - convert special ConTeXt-characters (PHP)

2011-11-01 Thread Aditya Mahajan

On Tue, 1 Nov 2011, Jan Heinen wrote:


Hello,

I am just programming a catalog which should be printed.

I have a lot of data, text and pictures in a MySQL-database and want to 
generate a nice catalog with ConTeXt.

To get the data from MySQL to ConTeXt I use PHP as an Interface:

MySQL -> PHP -> ConTeXt

And lot's of ConTeXt-macros will make a nice layout :-)

To give something back to this ConTeXt-community, I will put some helpfull 
PHP-functions into the wiki of contextgarden.net.


Today I wrote the function "ConvertToConteXt" which converts special 
ConTeXt-characters. You can see it below.



Before I put it into contextgarden.net ...
1. ... please test it.
2. You see three characters, where I don't know the code-number \char??? for 
ConTeXt. Do you know them?

3. Did I forget to convert a character?

Regards
Jannis



function ConvertToConteXt ( $xstring ) {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
*

*
*  author: Jörg Kopp
*  www.dr-kopp.com
*  01.11.2011
*
*  Convert special ConTeXt-characters with php
*  Works with PHP5
*
*  Call it with the string you want to convert ...
* ConvertToConteXt ($xstring);
*
*  ... and you get back the converted string
*
*  e.g.:
*  Input:
*  $string = "My root-Directory: /home/hans";
*  $string = ConvertToConteXt ( $string );
*
*  Output/Return:
*  $string = "My root\\char45Directory\\char58 
\\char47home\\char47hans";

*
*  When you write this into a file ...
*  file_put_contents ( "example.tex", "My 
root\\char45Directory\char58 \\char47home\\char47hans", FILE_APPEND );

*
*  ... You will find the following in example.tex:
*  My root\char45Directory\char58 \char47home\char47hans
*
*  An when you compile example.tex with ConTeXt
*  context example.text
*
*  You can read the following in the resulting example.pdf:
*  My root-Directory: /home/hans
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

 $xstring = html_entity_decode ( $xstring ); // convert 
HTML-entities into normal characters
 $xstring = str_replace ( "!",  "\\char33",  $xstring ); // 
Ausrufungszeichen/ConvertToConteXt
 $xstring = str_replace ( "\"", "\\char34",  $xstring ); // 
Anführungszeichen/quotation mark
 $xstring = str_replace ( "#",  "\\char35",  $xstring ); // Raute/number 
sign
 $xstring = str_replace ( "$",  "\\char36",  $xstring ); // 
Dollar-Zeichen/dollar sign
 $xstring = str_replace ( "%",  "\\char37",  $xstring ); // 
Prozent-Zeichen/percent sign
 $xstring = str_replace ( "&",  "\\char38",  $xstring ); // Kaufmännisches 
Und/ampersand
 $xstring = str_replace ( "'",  "\\char39",  $xstring ); // 
Apostroph/apostrophe
 $xstring = str_replace ( "(",  "\\char40",  $xstring ); // Klammer auf/left 
parenthesis
 $xstring = str_replace ( ")",  "\\char41",  $xstring ); // Klammer zu/right 
parenthesis

 $xstring = str_replace ( "*",  "\\char42",  $xstring ); // Stern/asterisk
 $xstring = str_replace ( "+",  "\\char43",  $xstring ); // Plus/plus sign
 $xstring = str_replace ( ",",  "\\char44",  $xstring ); // Komma/comma
 $xstring = str_replace ( "-",  "\\char45",  $xstring ); // Minus/hyphen
 $xstring = str_replace ( ".",  "\\char46",  $xstring ); // Punkt/period
 $xstring = str_replace ( "/",  "\\char47",  $xstring ); // 
Schrägstrich/period
 $xstring = str_replace ( ":",  "\\char58",  $xstring ); // 
Doppelpunkt/colon
 $xstring = str_replace ( ";",  "\\char59",  $xstring ); // 
Semikolon/semicolon
 $xstring = str_replace ( "<",  "\\char60",  $xstring ); // 
Kleinerzeichen/less-than
 $xstring = str_replace ( "=",  "\\char61",  $xstring ); // 
Gleichzeichen/equals-to
 $xstring = str_replace ( ">",  "\\char62",  $xstring ); // 
Größerzeichen/greater-than
 $xstring = str_replace ( "?",  "\\char63",  $xstring ); // 
Fragezeichen/question mark
 $xstring = str_replace ( "@",  "\\char64",  $xstring ); // at-Zeichen/at 
sign
 $xstring = str_replace ( "[",  "\\char91",  $xstring ); // eckige Klammer 
auf/left square bracket
 $xstring = str_replace ( "\\", "\\char92",  $xstring ); // 
Backslash/backslash
 $xstring = str_replace ( "]",  "\\char93",  $xstring ); // eckige Klammer 
zu/right square bracket

 $xstring = str_replace ( "^",  "\\char94",  $xstring ); // Zirkumflex/caret
 $xstring = str_replace ( "_",  "\\char95",  $xstring ); // 
Unterstrich/underscore
 //$xstring = str_replace ( "°",  "\\char",  $xstring ); // Grad/ < -- 
missing
 $xstring = str_replace ( "`",  "\\char96",  $xstring ); // accent 
aigu/acute accent
 $xstring = str_replace ( "{",  "\\char123", $xstring ); // geschweifte 
Klammer auf/left curly brace
 $xstring = str_replace ( "|",  "\\char124", $xstring ); // 
Pipezeichen/vertical bar
 $xstring = str_replace ( "}",  "\\char125", $xstring ); // geschweifte 
Klammer zu/right curly brace

 $xstring = str_replace ( "~",  "\\char126",  $xstring ); // Tilde/tilde
 //$xstring = str

Re: [NTG-context] ConvertToConteXt - convert special ConTeXt-characters (PHP)

2011-11-01 Thread Peter Münster
On Tue, Nov 01 2011, Jan Heinen wrote:

>   $xstring = str_replace ( "!",  "\\char33",  $xstring ); //

Why is "!" special in ConTeXt? (same question applies for many other characters)

With \asciimode there is probably only one character to convert: "\"
(and the sequence "%%", that should be quite rare)

-- 
   Peter
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] ConvertToConteXt - convert special ConTeXt-characters (PHP)

2011-11-01 Thread Jan Heinen

Hello,

I am just programming a catalog which should be printed.

I have a lot of data, text and pictures in a MySQL-database 
and want to generate a nice catalog with ConTeXt.

To get the data from MySQL to ConTeXt I use PHP as an Interface:

MySQL -> PHP -> ConTeXt

And lot's of ConTeXt-macros will make a nice layout :-)

To give something back to this ConTeXt-community, I will put 
some helpfull PHP-functions into the wiki of contextgarden.net.


Today I wrote the function "ConvertToConteXt" which converts 
special ConTeXt-characters. You can see it below.



Before I put it into contextgarden.net ...
1. ... please test it.
2. You see three characters, where I don't know the 
code-number \char??? for ConTeXt. Do you know them?

3. Did I forget to convert a character?

Regards
Jannis



function ConvertToConteXt ( $xstring ) {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* * * * * * * * *

 *
 *  author: Jörg Kopp
 *  www.dr-kopp.com
 *  01.11.2011
 *
 *  Convert special ConTeXt-characters with php
 *  Works with PHP5
 *
 *  Call it with the string you want to convert ...
 * ConvertToConteXt ($xstring);
 *
 *  ... and you get back the converted string
 *
 *  e.g.:
 *  Input:
 *  $string = "My root-Directory: /home/hans";
 *  $string = ConvertToConteXt ( $string );
 *
 *  Output/Return:
 *  $string = "My root\\char45Directory\\char58 
\\char47home\\char47hans";

 *
 *  When you write this into a file ...
 *  file_put_contents ( "example.tex", "My 
root\\char45Directory\char58 \\char47home\\char47hans", 
FILE_APPEND );

 *
 *  ... You will find the following in example.tex:
 *  My root\char45Directory\char58 
\char47home\char47hans

 *
 *  An when you compile example.tex with ConTeXt
 *  context example.text
 *
 *  You can read the following in the resulting 
example.pdf:

 *  My root-Directory: /home/hans
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* * * * * * * * */


  $xstring = html_entity_decode ( $xstring ); 
// convert HTML-entities into normal characters
  $xstring = str_replace ( "!",  "\\char33",  $xstring ); 
// Ausrufungszeichen/ConvertToConteXt
  $xstring = str_replace ( "\"", "\\char34",  $xstring ); 
// Anführungszeichen/quotation mark
  $xstring = str_replace ( "#",  "\\char35",  $xstring ); 
// Raute/number sign
  $xstring = str_replace ( "$",  "\\char36",  $xstring ); 
// Dollar-Zeichen/dollar sign
  $xstring = str_replace ( "%",  "\\char37",  $xstring ); 
// Prozent-Zeichen/percent sign
  $xstring = str_replace ( "&",  "\\char38",  $xstring ); 
// Kaufmännisches Und/ampersand
  $xstring = str_replace ( "'",  "\\char39",  $xstring ); 
// Apostroph/apostrophe
  $xstring = str_replace ( "(",  "\\char40",  $xstring ); 
// Klammer auf/left parenthesis
  $xstring = str_replace ( ")",  "\\char41",  $xstring ); 
// Klammer zu/right parenthesis
  $xstring = str_replace ( "*",  "\\char42",  $xstring ); 
// Stern/asterisk
  $xstring = str_replace ( "+",  "\\char43",  $xstring ); 
// Plus/plus sign
  $xstring = str_replace ( ",",  "\\char44",  $xstring ); 
// Komma/comma
  $xstring = str_replace ( "-",  "\\char45",  $xstring ); 
// Minus/hyphen
  $xstring = str_replace ( ".",  "\\char46",  $xstring ); 
// Punkt/period
  $xstring = str_replace ( "/",  "\\char47",  $xstring ); 
// Schrägstrich/period
  $xstring = str_replace ( ":",  "\\char58",  $xstring ); 
// Doppelpunkt/colon
  $xstring = str_replace ( ";",  "\\char59",  $xstring ); 
// Semikolon/semicolon
  $xstring = str_replace ( "<",  "\\char60",  $xstring ); 
// Kleinerzeichen/less-than
  $xstring = str_replace ( "=",  "\\char61",  $xstring ); 
// Gleichzeichen/equals-to
  $xstring = str_replace ( ">",  "\\char62",  $xstring ); 
// Größerzeichen/greater-than
  $xstring = str_replace ( "?",  "\\char63",  $xstring ); 
// Fragezeichen/question mark
  $xstring = str_replace ( "@",  "\\char64",  $xstring ); 
// at-Zeichen/at sign
  $xstring = str_replace ( "[",  "\\char91",  $xstring ); 
// eckige Klammer auf/left square bracket
  $xstring = str_replace ( "\\", "\\char92",  $xstring ); 
// Backslash/backslash
  $xstring = str_replace ( "]",  "\\char93",  $xstring ); 
// eckige Klammer zu/right square bracket
  $xstring = str_replace ( "^",  "\\char94",  $xstring ); 
// Zirkumflex/caret
  $xstring = str_replace ( "_",  "\\char95",  $xstring ); 
// Unterstrich/underscore
  //$xstring = str_replace ( "°",  "\\char",  $xstring ); 
// Grad/ < -- missing
  $xstring = str_replace ( "`",  "\\char96",  $xstring ); 
// accent aigu/acute accent
  $xstring = str_replace ( "{",  "\\char123", $xstring ); 
// geschweifte Klammer auf/left curly brace
  $xstring = str_replace ( "|",  "\\char124", $xstring ); 
// Pipezeichen/vertical bar
  $xstring = str_replace ( "}",  "\\char125", $xstring ); 
// geschweifte Klammer zu/right curly brace
  $xstring = str_replace ( "~",  "\\char126",  $xstri

[NTG-context] adjusting accents under slant

2011-11-01 Thread Idris Samawi Hamid ادريس سماوي حامد

Dear Hans and gang,

I got this working in mkii -- using other macros --, but mkiv is  
frustrating me:


==
%% Hans' bottom accent code
\unprotect
\unexpanded\def\bottomaccent#1#2#3#4#5% down right slantcorrection accent  
char

  {\dontleavehmode % why this align mess
   \vtop
 {\forgetall
  \baselineskip\zeropoint
  \lineskip#1%
  \everycr\emptytoks
  \tabskip\zeropoint
  \lineskiplimit\zeropoint
  \setbox0\hbox{#4}%
  \halign
{##\crcr\hbox{#5}\crcr
 \hidewidth
 \hskip#2\wd0
 \hskip-#3\slantperpoint % in plain 1ex * dimenless value
 \vbox to .2ex{\box0\vss}\hidewidth
 \crcr}}}

  \unexpanded\def\buildtextbottomdot
  {\bottomaccent{0ex}{4}{5}{\kern.1em\textbottomdot}}
\let\d\buildtextbottomdot
\protect

\defineactivecharacter ḥ  {\d{h}}

\starttext
ḥ {\it ḥ}
\stoptext
==

I need to adjust the horizontal position of the dot under the slanted  
char. I would assume the third parameter would control it but nothing  
seems to work.


Of course LM does not look so bad but I'm using a different font so this  
is just an illustration.


Best wishes
Idris
--
Professor Idris Samawi Hamid, Editor-in-Chief
International Journal of Shīʿī Studies
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

accent.tex
Description: TeX document
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] xtreme tables repeating header

2011-11-01 Thread Hans Hagen

On 29-10-2011 12:41, Patrick Gundlach wrote:

\setuppapersize [a5][a5]

\starttext

\setupxtable
   [width=.5\textwidth,
split=yes,
header=repeat,
footer=repeat]

\startxtable
  \startxtablehead
  \startxrow
   \startxcell  Column A \stopxcell
   \startxcell  Column B  \stopxcell
\stopxrow
\stopxtablehead
\startxtablenext
  \startxrow
   \startxcell  new column A \stopxcell
   \startxcell  new column B  \stopxcell
\stopxrow
\stopxtablenext
\startxtablebody
\startxrow
   \startxcell \vrule height  7cm \stopxcell
   \startxcell x \stopxcell
\stopxrow
\startxrow
   \startxcell \vrule height  7cm \stopxcell
   \startxcell x \stopxcell
\stopxrow
\startxrow
   \startxcell \vrule height  7cm \stopxcell
   \startxcell x \stopxcell
\stopxrow
\stopxtablebody

\stopxtable
\stoptext


quick hack:

\placefigure[split,fixed,none]{}{...}

currently only the the float related splitter will check the available 
space, so in your case you have a regular flush with skips between the 
rows and a header/footer only



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] xtreme tables repeating header

2011-11-01 Thread Hans Hagen

On 1-11-2011 13:54, Patrick Gundlach wrote:

Hello,

any news on this subject?

Thanks!


later, busy and away now

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] xtreme tables repeating header

2011-11-01 Thread Patrick Gundlach
Hello,

any news on this subject? 

Thanks!

Patrick



Am 29.10.2011 um 12:41 schrieb Patrick Gundlach:

> Hi,
> 
> I can't get the repeating header to work with the new extreme tables (the 
> "new column A" should be on the second page). What is the error here? 
> 
> Thanks
> 
> Patrick
> 
> 
> 
> \setuppapersize [a5][a5]
> 
> \starttext
> 
> \setupxtable
>  [width=.5\textwidth,
>   split=yes,
>   header=repeat,
>   footer=repeat]
> 
> \startxtable
> \startxtablehead
> \startxrow
>  \startxcell  Column A \stopxcell
>  \startxcell  Column B  \stopxcell
> \stopxrow
> \stopxtablehead
> \startxtablenext
> \startxrow
>  \startxcell  new column A \stopxcell
>  \startxcell  new column B  \stopxcell
> \stopxrow
> \stopxtablenext
> \startxtablebody
> \startxrow
>  \startxcell \vrule height  7cm \stopxcell
>  \startxcell x \stopxcell
> \stopxrow
> \startxrow
>  \startxcell \vrule height  7cm \stopxcell
>  \startxcell x \stopxcell
> \stopxrow
> \startxrow
>  \startxcell \vrule height  7cm \stopxcell
>  \startxcell x \stopxcell
> \stopxrow
> \stopxtablebody
> 
> \stopxtable
> \stoptext
> 

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] color and textext

2011-11-01 Thread Meer, H. van der
After some struggling with text colouring in metafun I finally encountered on 
the wiki:

Another difference is the way text is handled in mkiv. In particular, color 
(withcolor) is not applied to metapost text. For example,
draw thelabel(decimal i, (i, 0) scaled 1cm) withcolor red ;

currently does not work in mkiv. However,
label(textext("\color[red]"& decimal i), (i, 0) scaled 1cm);

does work. This second solution works both in mkiv and in mkii. (Note that 
\color[red] can be abbreviated \red.)


My question: is currently in "currently does not work in mkiv" in fact 
permanently or will this restriction soon be lifted? If the restriction is here 
to stay, I will have to find a workaround for my label-typesetting code in 
metapost.

Or perhaps someone can tell me how to make "textext" use a color existing in 
the "metapost world". That would work as well.

Explaining my setup:
The colors are taken up in metapost with
   def defineColors (expr outlineColor, …) … outlinecolor_ := outlineColor … 
enddef;
which is called in ConTeXt as …(\MPcolor{aColor}…
But I do not know how to transform the \MPcolor{aColor} back into a form to be 
used as for example
  textext("…

Hans van der Meer



___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] Scite-syntax-highlighting (solved)

2011-11-01 Thread Jan Heinen

Hello,

problem solved!

1. I made a new installation of Scite
2. put the lexer from scintillua into the 
scite-rootdirectory (including the directoryname /lexer/)

3. and then the lexer from my context-installation

And now highlighting works :-)

Regards
Jannis

___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___