Hi!
It looks very good! In my opinion the template will be more interesting (but also more heavy) if you work directly with the Index page by loading its content (local page = mw.title.new( 'Index:XXX.djvu' ); local text = page:getContent()) and parsing the <pagelist> tag that will give you the displayed number <-> number in the djvu conversion.
Thomas
Date: Fri, 31 May 2013 16:10:47 +0200 From: alex.brollo@gmail.com To: wikisource-l@lists.wikimedia.org Subject: [Wikisource-l] Playing with Lua, javascript and pagelist tag
I'm testing a template [:it:s:Template:Pg]] (calling a Lua module) that fastly converts book page numbers, passed as the unique parameter to the template, into links to right djvu pages, without any need to add delta parameters and linking any format for page number (arabic, roman, other...) since page numbers are seen as strings.
The Lua script reads a data page, containing tables for conversion book page->djvu page and reverse, using mw.loadData() function for max efficiency (often there are dozens, sometimes hundreds of links to pages into a single book page; ity happens into analytical indexes, glossaries and so on).
The Lua data page is written in a eyeblink by a js script, which reads and parses html of Index: page, produced by pagelist tag; so it's very comfortable to fill such data page and to update it, if pagelist parameters are updated.
Is this "beginner's Lua exercise" someway interesting/inspiring in your opinion? Alex brollo
_______________________________________________ Wikisource-l mailing list Wikisource-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikisource-l