diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-07 08:21:43 -0700 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-05-07 08:21:43 -0700 |
commit | ecd4cdef5b0c98dbaa4c6f0988e29f0c72e72b84 (patch) | |
tree | 68fffe461c3b61385ef74e25eb40a4747d36ea49 | |
parent | b7f3f777b1c825e4b4e0c8d6ec5592090078f36b (diff) | |
parent | a12c25a4a074c87557c211ab0c98c0dff5e7d470 (diff) | |
download | luatexbase-ecd4cdef5b0c98dbaa4c6f0988e29f0c72e72b84.tar.gz |
Merge pull request #1 from lualatex/master
sync with current
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | NEWS (renamed from Changes) | 3 | ||||
-rw-r--r-- | README | 12 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | luatexbase-modutils.dtx | 71 |
5 files changed, 61 insertions, 32 deletions
@@ -33,7 +33,7 @@ UNPACKEDTL = $(UNPACKED_MCB) $(UNPACKED_REGS) $(UNPACKED_ATTR) $(UNPACKED_CCTB) $(UNPACKED_BASE) COMPILED = $(DOC) GENERATED = $(COMPILED) $(UNPACKED) -SOURCE = $(DTX) $(DTXSTY) README TODO Changes Makefile +SOURCE = $(DTX) $(DTXSTY) README TODO NEWS Makefile # used for check TEST_LOADER = test-loader @@ -42,7 +42,7 @@ TEST_MCB = test-mcb-aux.tex # Files grouped by installation location RUNFILES = $(filter-out test-%, $(UNPACKEDTL)) -DOCFILES = $(DOC) $(filter test-%, $(UNPACKEDTL)) README TODO Changes +DOCFILES = $(DOC) $(filter test-%, $(UNPACKEDTL)) README TODO NEWS SRCFILES = $(DTX) Makefile # The following definitions should be equivalent @@ -1,6 +1,8 @@ Changes in the luatexbase package/bundle 2013/05/04 v0.6 + all + - move away from the module() function (deprecated in Lua 5.2) attr - hack to make luatexbase and luatex.sty compatible for attribute allocation (same thing should be done for catcodetables) @@ -8,6 +10,7 @@ modutils - adding functions to check the availability and version of a module - fixing small error in module date requirement + - update documentation to reflect the move from module() loader - do not output included file paths when called by texlua mcb @@ -22,16 +22,10 @@ Installation Here are the recommended installation methods (preferred first). 1. If you are using TeX Live 2010 or later, use 'tlmgr install luatexbase'. -If your are using MiKTeX, use the MiKTeX Package Manager. -Alternatively, try you Linux distribution's package management system. + If your are using MiKTeX, use the MiKTeX Package Manager. + Alternatively, try you Linux distribution's package management system. -2. a. Grab luatexbase.tds.zip on the CTAN. - b. Unzip it at the root of one or your TDS trees. - c. You may need to update some filename database after this, see your TeX - distribution's manual for details. (Hint: with TeX Live, run 'mktexlsr'; - with MikTeX, look for "Refresh FNDB" in the MikTeX menu.) - -3. a. Grab the sources from CTAN or github. +2. a. Grab the sources from CTAN or github. b. Run 'make install TEXMFROOT=/path/to/texmf'. (Warning: 'make install' without giving a TEXMFROOT will put files in './texmf', which is probably not what you want.) @@ -29,6 +29,7 @@ cctb ---- - support for unicode-letters? +- make the functions compatible with luatex.sty mcb --- @@ -38,7 +39,7 @@ mcb - provide a list()? - allow temporary disabling of callbacks - do something with open_read_file etc -- make callback.register = luatexbase_add_to_callback +- make callback.register = luatexbase_add_to_callback? - check if there are functions in the callbacks before luatexbase is loaded and import them diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx index d9fd34a..cd1458a 100644 --- a/luatexbase-modutils.dtx +++ b/luatexbase-modutils.dtx @@ -144,17 +144,10 @@ See the aforementioned source file(s) for copyright and licensing information. % % \medskip % -% It is important to notice that Lua's standard function |module()| is -% completely orthogonal with the present package. It has nothing to do with -% identification and deals only with namespaces: more precisely, it -% modifies the current environment. So, you should continue to -% use it normally regardless of whether you chose to use this package's -% features for identification. -% -% It is recommended to always use |module()| or any other method that ensure -% the global name space remains clean. For example, you may heavily use the -% |local| keyword and explicitly qualify the name of every non-local symbol. -% Chapter 15 of \href{http://www.lua.org/pil/}{Programming in Lua, 1st ed.} +% It is important to note that Lua's unction |module()| is deprecated in +% Lua 5.2 and should be avoided. For examples of good practices for creating +% modules, see section~\ref{template}. Chapter 15 +% of \href{http://www.lua.org/pil/15.html}{Programming in Lua, 3rd ed.} % discusses various methods for managing packages. % % \subsection{\tex macros} @@ -232,18 +225,14 @@ See the aforementioned source file(s) for copyright and licensing information. % \begin{qcode} % local module_info = luatexbase.get_module_info(\meta{name}) % local version = luatexbase.get_module_version(\meta{name}) +% local date = luatexbase.get_module_date(\meta{name}) +% local date_int = luatexbase.get_module_date_int(\meta{name}) % local is_loaded = luatexbase.is_module_loaded(\meta{name}) % \end{qcode} % These functions check for the availability or version of a module, and can % even return a copy of the |module_info| table. % -% \subsection{Templates} -% -% Let me emphasize again that, while |luatexbase.require_module()| is meant to -% be used as a replacement for |require()|, the function -% |luatexbase.provides_module()| \emph{is not} a replacement for |module()|: -% they just don't do the same thing (declaring information vs changing the -% current name space). +% \subsection{Templates}\label{template} % % Now, here is a module header template showing all the recommended elements: % \begin{verbatim} @@ -468,6 +457,7 @@ See the aforementioned source file(s) for copyright and licensing information. %<*luamodule> luatexbase = luatexbase or { } local luatexbase = luatexbase +local string_gsub = string.gsub % \end{macrocode} % % \subsection{Internal functions and data} @@ -484,7 +474,8 @@ local modules = modules or {} % % \begin{macrocode} local function date_to_int(date) - local numbers = string.gsub(date, "(%d+)/(%d+)/(%d+)", "%1%2%3") + if date == '' then return -1 end + local numbers = string_gsub(date, "(%d+)/(%d+)/(%d+)", "%1%2%3") return tonumber(numbers) end % \end{macrocode} @@ -635,7 +626,8 @@ end luatexbase.get_module_info = get_module_info % \end{macrocode} % -% Gives the version of a module, or nil if the module is not loaded. +% Gives the version of a module, nil if the module is not loaded and empty +% string if the module did not set its date. % % \begin{macrocode} function get_module_version(name) @@ -649,6 +641,37 @@ end luatexbase.get_module_version = get_module_version % \end{macrocode} % +% Gives the date string of a module, nil if the module is not loaded and +% empty string of the modules did not set its date. +% +% \begin{macrocode} +function get_module_date(name) + local module_table = modules[name] + if not module_table then + return nil + else + return module_table.date + end +end +luatexbase.get_module_date = get_module_date +% \end{macrocode} +% +% Gives the date number of a module, for date comparison, nil if the +% module is not loaded and -1 if the module did not set its date. The number +% is formated as |yyyymmdd|. +% +% \begin{macrocode} +function get_module_date_int(name) + local module_table = modules[name] + if not module_table then + return nil + else + return module_table.date and date_to_int(module_table.date) + end +end +luatexbase.get_module_date_int = get_module_date_int +% \end{macrocode} +% % Returns true if the module is loaded, false otherwise. % % \begin{macrocode} @@ -678,6 +701,12 @@ local err, warn, info, log = luatexbase.provides_module { version = 1, description = 'dummy test package', } +luatexbase.provides_module { + name = 'test-modutils2', + date = '', + version = 1, + description = 'dummy test package', +} info('It works!\nOh, rly?\nYeah rly!') log("I'm a one-line info.") info("1 = "..luatexbase.get_module_version('test-modutils')) @@ -687,6 +716,8 @@ else err("problem!") end info("2000/01/01 = "..luatexbase.get_module_info('test-modutils').date) +info("20000101 = "..luatexbase.get_module_date_int('test-modutils')) +info("-1 = "..luatexbase.get_module_date_int('test-modutils2')) %</testdummy> % \end{macrocode} % |