From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: t-inifile, my first experience with lua
Date: Tue, 26 Feb 2008 00:10:55 +0100 [thread overview]
Message-ID: <47C34AFF.50905@wxs.nl> (raw)
In-Reply-To: <20080225220112.GA1981@gaston.couberia.bzh>
Peter Münster wrote:
> Hello,
>
> Hey, it's really fun to code in lua: pattern matching, easy table
> manipulation and so on, I should have learned it earlier!
>
> Since it's my first experience with lua, I would like to ask you for
> comments on the t-inifile.tex module, attached to this message.
>
> I tried to implement a demo-mode, but there are two small problems:
> - I don't know how to use \savebuffer, all line-endings disappear in the
> saved file
> - the utf-thinspace is ignored
>
> Cheers and thanks a lot to the luatex and MKIV developers!
i have no time to look into it ... a few comments ...
inifile = {}
^^^
there are three predefined namespaces:
userdata = userdata or { }
thirddata = thirddata or { }
document = document or { }
in your case, use
thirddata.inifile = { }
-- just for debugging: print the table to stdout
local function print_table()
for i = 1,#inifile.t do
print("")
print(i, inifile.t[i].key)
for k, v in pairs(inifile.t[i]) do
print("", k, v)
end
print("")
end
end
just do:
print(table.serialize(thirddata.inifile.t)
(there are quite some helpers defined in l-string, l-table cum suis)
-----------------------------------------------------------------
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2008-02-25 23:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 22:01 Peter Münster
2008-02-25 22:46 ` Aditya Mahajan
2008-02-25 22:57 ` Peter Münster
2008-02-25 23:10 ` Hans Hagen [this message]
2008-02-25 23:23 ` Peter Münster
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=47C34AFF.50905@wxs.nl \
--to=pragma@wxs.nl \
--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).