diff options
author | Marius <mariausol@gmail.com> | 2013-10-20 01:21:09 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-10-20 01:21:09 +0300 |
commit | b8ac6d7b7fdb16293c28034c349efd5b0b7b20b3 (patch) | |
tree | 0e9051dbe21b4e9cfc72fe594df5b0fe7bc511f3 /tex/context/base/m-zint.mkiv | |
parent | 965214d981e6129b782c67adcaf3a81aedcb0bac (diff) | |
download | context-b8ac6d7b7fdb16293c28034c349efd5b0b7b20b3.tar.gz |
beta 2013.10.20 07:09
Diffstat (limited to 'tex/context/base/m-zint.mkiv')
-rw-r--r-- | tex/context/base/m-zint.mkiv | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/tex/context/base/m-zint.mkiv b/tex/context/base/m-zint.mkiv index 95b265c57..4957c8461 100644 --- a/tex/context/base/m-zint.mkiv +++ b/tex/context/base/m-zint.mkiv @@ -29,17 +29,21 @@ moduledata.zint = { } local format, lower, gsub = string.format, string.lower, string.gsub local patterns = lpeg.patterns -local zint = "zint" -- '"c:/program files/zint/zint.exe"' +local zint = "zint" -- '"c:/program files/zint/zint.exe"' +local defaultcode = "PDF417" -local whitespace = patterns.whitespace -local spaces = whitespace^0 -local key = (spaces / "") * patterns.digit^0 * (patterns.colon * spaces / "") -local value = (whitespace / "" + (1 - key))^1 -local pattern = lpeg.Cf(lpeg.Ct("") * (lpeg.Cg((lpeg.Cs(key) / tonumber) * (lpeg.Cs(value) / lower)) + patterns.anything)^0,rawset) +local whitespace = patterns.whitespace +local spaces = whitespace^0 +local key = (spaces / "") * patterns.digit^0 * (patterns.colon * spaces / "") +local value = (whitespace / "" + (1 - key))^1 +local pattern = lpeg.Cf(lpeg.Ct("") * (lpeg.Cg((lpeg.Cs(key) / tonumber) * (lpeg.Cs(value) / lower)) + patterns.anything)^0,rawset) local reverse local function cleancode(code) + if not code or code == "" then + code = defaultcode + end return lower(gsub(code," ","")) end @@ -76,6 +80,19 @@ end \stopluacode +\unprotect + +\unexpanded\def\barcode[#1]% [alternative=,text=] + {\bgroup + \getdummyparameters + [\c!alternative=,\c!text=,#1]% + \externalfigure + [\cldcontext{moduledata.zint.generate("\dummyparameter\c!alternative",\!!bs\dummyparameter\c!text\!!es)}]% + [#1,\c!alternative=,\c!text=]% + \egroup} + +\protect + \continueifinputfile{m-zint.mkiv} \starttext @@ -85,6 +102,10 @@ end \externalfigure[\cldcontext{moduledata.zint.generate("PDF417","Ton Otten")}] \blank \externalfigure[\cldcontext{moduledata.zint.generate("ISBN","9789490688011")}] + \blank + \barcode[text=Does It Work?,width=\textwidth] + \blank + \barcode[alternative=isbn,text=9789490688011,width=3cm] \stoptext |