From: "Peter Münster" <pmlists@free.fr>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Various ConTeXt Questions
Date: Thu, 3 Apr 2008 21:44:03 +0200 [thread overview]
Message-ID: <20080403194403.GA6602@gaston.couberia.bzh> (raw)
In-Reply-To: <a6e8c1d0804030944r6d22ce05o1848bc1a244455e4@mail.gmail.com>
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
___________________________________________________________________________________
prev parent reply other threads:[~2008-04-03 19:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-02 14:46 Edd Barrett
2008-04-03 8:11 ` Wolfgang Schuster
2008-04-03 8:46 ` Edd Barrett
2008-04-03 8:31 ` Hans Hagen
2008-04-03 10:49 ` Mojca Miklavec
2008-04-03 11:59 ` Aditya Mahajan
2008-04-03 16:44 ` Edd Barrett
2008-04-03 19:44 ` Peter Münster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080403194403.GA6602@gaston.couberia.bzh \
--to=pmlists@free.fr \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).