Re: [NTG-context] What is the luatex version of \pdfescapehex

2010-01-06 Thread Zhichu Chen
Sorry to my previous posts. I found a LaTeX package named pdftexcmds
and the lua script works just fine.
___
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] What is the luatex version of \pdfescapehex

2010-01-06 Thread Zhichu Chen
Thank you Hans,

On Wed, Jan 6, 2010 at 4:38 PM, Hans Hagen  wrote:
> On 6-1-2010 2:33, Zhichu Chen wrote:
>>
>> Hi,
>>
>> I've written a very old module which used a lot of pdf primitives like
>> \pdfescapehex
>> and \pdfescapename etc. and it turns out not they don't work in mkiv.
>> So I just want
>> to know are there any alternatives?
>
> just lua code as placeholders for primitives will not show up in context
> mkiv
>
> \startluacode
>    local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
>    local gsub, format, byte = string.gsub, string.format, string.byte
>    function commands.hexify(str)
>        texsprint(ctxcatcodes,(gsub(str,".",function(s) return
> format("%0X",byte(s)) end)))
>    end
> \stopluacode
>
> \long\def\hexify#1{\ctxlua{commands.hexify([[#1]])}}
>
>
> \hexify{I wonder why this is needed.}
>
>
> btw, if your old module produces pdf and uses other \pdf... primitives it's
> unlikely to work with mkiv anyway so you'd better check if it's still needed
Yes, \pdffilemoddate, \pdffilesize, \pdfmdfivesum are kind of disabled as well,
I'm not familiar with lua at all, so I don't know how to replace them with the
lua version. I did change your code format("%0X",byte(s)) with
format("%s",byte(s))
and it worked as \pdfescapename. I hope I'm not too wrong.

Anyway, my ancient module just write directly with pdfobj, I just commented
the /ModDate parameters and seems just fine now.

I think I really need to learn some lua. Thank you again for your time.

>
> Hans
>
> -
>                                          Hans Hagen | PRAGMA ADE
>              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
>                                             | www.pragma-pod.nl
> -
>



-- 
Best Regards
Chen


  Zhi-chu Chen | Shanghai Synchrotron Radiation Facility
 No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China
 tel: 086 21 5955 3405 | zhichu.chen.googlepages.com
   | www.sinap.ac.cn

___
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] What is the luatex version of \pdfescapehex

2010-01-06 Thread Hans Hagen

On 6-1-2010 2:33, Zhichu Chen wrote:

Hi,

I've written a very old module which used a lot of pdf primitives like
\pdfescapehex
and \pdfescapename etc. and it turns out not they don't work in mkiv.
So I just want
to know are there any alternatives?


just lua code as placeholders for primitives will not show up in context 
mkiv


\startluacode
local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
local gsub, format, byte = string.gsub, string.format, string.byte
function commands.hexify(str)
texsprint(ctxcatcodes,(gsub(str,".",function(s) return 
format("%0X",byte(s)) end)))

end
\stopluacode

\long\def\hexify#1{\ctxlua{commands.hexify([[#1]])}}


\hexify{I wonder why this is needed.}


btw, if your old module produces pdf and uses other \pdf... primitives 
it's unlikely to work with mkiv anyway so you'd better check if it's 
still needed


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 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
___


[NTG-context] What is the luatex version of \pdfescapehex

2010-01-05 Thread Zhichu Chen
Hi,

I've written a very old module which used a lot of pdf primitives like
\pdfescapehex
and \pdfescapename etc. and it turns out not they don't work in mkiv.
So I just want
to know are there any alternatives?

TIA

-- 
Best Regards
Chen


  Zhi-chu Chen | Shanghai Synchrotron Radiation Facility
 No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China
 tel: 086 21 5955 3405 | zhichu.chen.googlepages.com
   | www.sinap.ac.cn

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