On Thu, Apr 03 2008, Edd Barrett wrote:

> Just a way of isolating each of the marco's values that cvs defines. How 
> about:
> 
> ---8<---
> \definecvskeyword[cvsdate][D/M/Y]{$Date$}% will be expanded upon
> commit to something like $Date: 1999/12/23 01:59:22 $
> \starttext
> Last Updated: \cvskeyword[cvsdate]
> \stoptext
> ---8<---
> 
> would produce:
> Last Updated: 1999/12/23 01:59:22

Hello Edd,

Perhaps like this:

% engine=luatex

\startluacode
thirddata = thirddata or { }

-- write the replacement string
-- p: pattern
-- r: replacement pattern
-- s: subject
function thirddata.replace(p, r, s)
        s = string.gsub(s, "^.-" .. p .. ".-$", r)
        tex.print(s)
end
\stopluacode

\def\definereplacement{\doquadrupleargument\dodefinereplacement}

\def\dodefinereplacement[#1][#2][#3][#4]{\expandafter
  \def\csname #1\endcsname{\ctxlua{thirddata.replace("#2", "#3", "#4")}}}

\definereplacement[cvsdate] [(\%d+)/(\%d+)/(\%d+)] [\%3.\%2.\%1]
                  [$Date: 1999/12/23 01:59:22 $]
\definereplacement[cvstime] [(\%d+):(\%d+):(\%d+)] [\%1h \%2m \%3s]
                  [$Date: 1999/12/23 01:59:22 $]
\definereplacement[cvsfile] [: (.+),] [\\type{\%1}]
                  [$RCSfile: keyword.html,v $]

\starttext
File: \cvsfile, last Updated: \cvsdate\ at \cvstime
\stoptext


Cheers, Peter

-- 
http://pmrb.free.fr/contact/

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to