ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Using LateX packages
  2005-01-25 13:52 Using LateX packages Holger Peters
@ 2005-01-25 13:00 ` luigi scarso
  2005-01-25 16:48 ` h h extern
  2005-01-25 21:16 ` Patrick Gundlach
  2 siblings, 0 replies; 6+ messages in thread
From: luigi scarso @ 2005-01-25 13:00 UTC (permalink / raw)


Holger Peters wrote:

> Hi,
>
> I want to use a LaTeX Package (clrscode), or at least I want to port 
> it to Context.
>
> http://www.cs.dartmouth.edu/~thc/clrscode/
>
> Is there some way to use LaTex Packages (I guess not).
>
> Is there documentation about writing ConTeXt modules? (I didn't find 
> any).
>
> -- Holger
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
I always look into TEXMFMAIN/tex/context/base and try to figure how to 
make what I want;
on pragma site there are some docs  about to make pdf for  documentation.

luigi

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

* Using LateX packages
@ 2005-01-25 13:52 Holger Peters
  2005-01-25 13:00 ` luigi scarso
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Holger Peters @ 2005-01-25 13:52 UTC (permalink / raw)


Hi,

I want to use a LaTeX Package (clrscode), or at least I want to port it 
to Context.

http://www.cs.dartmouth.edu/~thc/clrscode/

Is there some way to use LaTex Packages (I guess not).

Is there documentation about writing ConTeXt modules? (I didn't find any).

-- Holger

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

* Re: Using LateX packages
  2005-01-25 13:52 Using LateX packages Holger Peters
  2005-01-25 13:00 ` luigi scarso
@ 2005-01-25 16:48 ` h h extern
  2005-01-26 13:27   ` Holger Peters
  2005-01-25 21:16 ` Patrick Gundlach
  2 siblings, 1 reply; 6+ messages in thread
From: h h extern @ 2005-01-25 16:48 UTC (permalink / raw)


Holger Peters wrote:
> Hi,
> 
> I want to use a LaTeX Package (clrscode), or at least I want to port it 
> to Context.
> 
> http://www.cs.dartmouth.edu/~thc/clrscode/

hm, not complex but mostly calls to latex font switches ans such

> Is there some way to use LaTex Packages (I guess not).

so you need to rewrite it

> Is there documentation about writing ConTeXt modules? (I didn't find any).

- try to use high level constructs (or ask me to provide them -)
- only use low level macroe documented in syst-*.tex and supp-*.tex (the ones 
mentioned in \macros, not the \dododo things)
- think fresh, forget about how other packages do it, think about what *you* 
want / need
- user modules are prefixed with t- (m- x- p- and s- are reserved for core 
modules and styles)

Now, about your code beautifier. Since you end up with additional markup anyway, 
why not go XML. You can then embed that in you tex document as usual (and have 
the full power of context available) but also use the code in webpages.

To give you an idea:

\starttext

\long\def\startcode#1\stopcode
  {\begingroup
   \startXMLmapping[code]%
   \enableXML\scantokens{#1}%
   \stopXMLmapping
   \endgroup}

\newcount\codedepth
\newdimen\codeindent \codeindent=1em

\def\incrementcodedepth
   {\advance\codedepth\plusone
    \ifnum\codedepth>\plusone \advance\leftskip\codeindent \fi
    \relax}

\def\decrementcodedepth
   {\ifnum\codedepth>\plusone \advance\leftskip-\codeindent \fi
    \advance\codedepth\minusone
    \relax}

\defineregister[function][functions]
\setupregister[function][expansion=yes]

\startXMLmapping[code]

   \defineXMLsingular [if]   {\endgraf{\bf if}\incrementcodedepth}
   \defineXMLsingular [then] {{\bf then}\endgraf\incrementcodedepth}
   \defineXMLsingular [else] {\endgraf\decrementcodedepth{\bf 
else}\endgraf\incrementcodedepth}
   \defineXMLsingular [end]  {\endgraf{\bf end}\decrementcodedepth\endgraf}

   \defineXMLsingular [int]  {{\bf int}\space\ignorespaces}
   \defineXMLsingular [bool] {{\bf bool}\space\ignorespaces}

   \defineXMLsingular [var]  [id='x'] {{\tf \XMLop{id}}}

   \defineXMLenvironment [function] [id=unknown]
     {\endgraf\function{\XMLop{id}}{\bf function}\space{\sl\XMLop{id}}\space}
     {\endgraf\incrementcodedepth}

   \defineXMLenvironment [return]
     {{\bf return}\space}
     {\endgraf}

   \defineXMLenvironment [c]
     {\bgroup\setups{code:comment}\type{//* }\ignorespaces}
     {\removeunwantedspaces\type{ *//}\egroup\endgraf}

\stopXMLmapping

\startsetups [code:comment]

   \defineXMLsingular [var]  [id='x'] {{\bs \XMLop{id}}}

\stopsetups

\startcode
<function id='ExampleFunction'>(<bool/> i; <int/> j)</function>
     <if/> (i&lt;10) <then/>
        <c>Let's add some comment here. Well, <var id='a'/> means nothing to me.</c>
        <var id='a'/> := 3
     <else/>
        <c>This is a funny language, a kind of mixture.</c>
        <var id='a'/> := 1
     <end/>
     <return>a</return>
<end/>
\stopcode

\blank[3*big]\placeregister[function][criterium=all]

\stoptext

If there is interest in such a module, i can write the auxiliary macros needed 
for it and others can define the languages.

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

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

* Re: Using LateX packages
  2005-01-25 13:52 Using LateX packages Holger Peters
  2005-01-25 13:00 ` luigi scarso
  2005-01-25 16:48 ` h h extern
@ 2005-01-25 21:16 ` Patrick Gundlach
  2005-01-26  6:42   ` Re: Using LateX packages => for algorithms Maurice Diamantini
  2 siblings, 1 reply; 6+ messages in thread
From: Patrick Gundlach @ 2005-01-25 21:16 UTC (permalink / raw)


Hello Holger,

> I want to use a LaTeX Package (clrscode), or at least I want to port
> it to Context.
>
> http://www.cs.dartmouth.edu/~thc/clrscode/
>
> Is there some way to use LaTex Packages (I guess not).

No. The low level commands are different in LaTeX and ConTeXt. The
named package does not use a lot of unique LaTeX features, so a port
shouldn't be too difficult. But as I guess from your question, you are
unable to do that, so the question is: who else does the job? And I
guess, nobody rises his hand now.


> Is there documentation about writing ConTeXt modules? (I didn't find any).

There is an API documentation project.... Taco has written a paper on
some commands, but there is much more to do.

Patrick
-- 
ConTeXt wiki: http://contextgarden.net

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

* Re: Re: Using LateX packages => for algorithms
  2005-01-25 21:16 ` Patrick Gundlach
@ 2005-01-26  6:42   ` Maurice Diamantini
  0 siblings, 0 replies; 6+ messages in thread
From: Maurice Diamantini @ 2005-01-26  6:42 UTC (permalink / raw)
  Cc: Maurice Diamantini


Bonjour à tous !

Le 25 janv. 05, à 22:16, Patrick Gundlach a écrit :

> Hello Holger,
>
>> I want to use a LaTeX Package (clrscode), or at least I want to port
>> it to Context.
>>
>> http://www.cs.dartmouth.edu/~thc/clrscode/
>>
>> Is there some way to use LaTex Packages (I guess not).
>
> No. The low level commands are different in LaTeX and ConTeXt. The
> named package does not use a lot of unique LaTeX features, so a port
> shouldn't be too difficult. But as I guess from your question, you are
> unable to do that, so the question is: who else does the job? And I
> guess, nobody rises his hand now.

See HH answer about a similar request.
I think this solution could be the start of your package.

Hans had extended the startlines environment with an option
which keep spaces, so that it's easier to write
algorithms without having some \it begining every lines !

http://www.ntg.nl/pipermail/ntg-context/2004/008169.html

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

* Re: Using LateX packages
  2005-01-25 16:48 ` h h extern
@ 2005-01-26 13:27   ` Holger Peters
  0 siblings, 0 replies; 6+ messages in thread
From: Holger Peters @ 2005-01-26 13:27 UTC (permalink / raw)


Hi,

thanks, that's a good start for me.

-- Holger

h h extern wrote:

> Holger Peters wrote:
>
>> Hi,
>>
>> I want to use a LaTeX Package (clrscode), or at least I want to port 
>> it to Context.
>>
>> http://www.cs.dartmouth.edu/~thc/clrscode/
>
>
> hm, not complex but mostly calls to latex font switches ans such
>
>> Is there some way to use LaTex Packages (I guess not).
>
>
> so you need to rewrite it
>
>> Is there documentation about writing ConTeXt modules? (I didn't find 
>> any).
>
>
> - try to use high level constructs (or ask me to provide them -)
> - only use low level macroe documented in syst-*.tex and supp-*.tex 
> (the ones mentioned in \macros, not the \dododo things)
> - think fresh, forget about how other packages do it, think about what 
> *you* want / need
> - user modules are prefixed with t- (m- x- p- and s- are reserved for 
> core modules and styles)
>
> Now, about your code beautifier. Since you end up with additional 
> markup anyway, why not go XML. You can then embed that in you tex 
> document as usual (and have the full power of context available) but 
> also use the code in webpages.
>
> To give you an idea:
>
> \starttext
>
> \long\def\startcode#1\stopcode
>  {\begingroup
>   \startXMLmapping[code]%
>   \enableXML\scantokens{#1}%
>   \stopXMLmapping
>   \endgroup}
>
> \newcount\codedepth
> \newdimen\codeindent \codeindent=1em
>
> \def\incrementcodedepth
>   {\advance\codedepth\plusone
>    \ifnum\codedepth>\plusone \advance\leftskip\codeindent \fi
>    \relax}
>
> \def\decrementcodedepth
>   {\ifnum\codedepth>\plusone \advance\leftskip-\codeindent \fi
>    \advance\codedepth\minusone
>    \relax}
>
> \defineregister[function][functions]
> \setupregister[function][expansion=yes]
>
> \startXMLmapping[code]
>
>   \defineXMLsingular [if]   {\endgraf{\bf if}\incrementcodedepth}
>   \defineXMLsingular [then] {{\bf then}\endgraf\incrementcodedepth}
>   \defineXMLsingular [else] {\endgraf\decrementcodedepth{\bf 
> else}\endgraf\incrementcodedepth}
>   \defineXMLsingular [end]  {\endgraf{\bf 
> end}\decrementcodedepth\endgraf}
>
>   \defineXMLsingular [int]  {{\bf int}\space\ignorespaces}
>   \defineXMLsingular [bool] {{\bf bool}\space\ignorespaces}
>
>   \defineXMLsingular [var]  [id='x'] {{\tf \XMLop{id}}}
>
>   \defineXMLenvironment [function] [id=unknown]
>     {\endgraf\function{\XMLop{id}}{\bf 
> function}\space{\sl\XMLop{id}}\space}
>     {\endgraf\incrementcodedepth}
>
>   \defineXMLenvironment [return]
>     {{\bf return}\space}
>     {\endgraf}
>
>   \defineXMLenvironment [c]
>     {\bgroup\setups{code:comment}\type{//* }\ignorespaces}
>     {\removeunwantedspaces\type{ *//}\egroup\endgraf}
>
> \stopXMLmapping
>
> \startsetups [code:comment]
>
>   \defineXMLsingular [var]  [id='x'] {{\bs \XMLop{id}}}
>
> \stopsetups
>
> \startcode
> <function id='ExampleFunction'>(<bool/> i; <int/> j)</function>
>     <if/> (i&lt;10) <then/>
>        <c>Let's add some comment here. Well, <var id='a'/> means 
> nothing to me.</c>
>        <var id='a'/> := 3
>     <else/>
>        <c>This is a funny language, a kind of mixture.</c>
>        <var id='a'/> := 1
>     <end/>
>     <return>a</return>
> <end/>
> \stopcode
>
> \blank[3*big]\placeregister[function][criterium=all]
>
> \stoptext
>
> If there is interest in such a module, i can write the auxiliary 
> macros needed for it and others can define the languages.
>
> 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
> -----------------------------------------------------------------
>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>

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

end of thread, other threads:[~2005-01-26 13:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-25 13:52 Using LateX packages Holger Peters
2005-01-25 13:00 ` luigi scarso
2005-01-25 16:48 ` h h extern
2005-01-26 13:27   ` Holger Peters
2005-01-25 21:16 ` Patrick Gundlach
2005-01-26  6:42   ` Re: Using LateX packages => for algorithms Maurice Diamantini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).