summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/chem-str.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
commit57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch)
tree1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/tex/context/base/chem-str.lua
parent6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff)
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/chem-str.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/chem-str.lua24
1 files changed, 13 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/context/base/chem-str.lua b/Master/texmf-dist/tex/context/base/chem-str.lua
index 8ab48fca2af..ad4cc6c1be4 100644
--- a/Master/texmf-dist/tex/context/base/chem-str.lua
+++ b/Master/texmf-dist/tex/context/base/chem-str.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['chem-str'] = {
version = 1.001,
- comment = "companion to chem-str.tex",
+ comment = "companion to chem-str.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
@@ -17,6 +17,7 @@ local format, gmatch, match, lower, gsub = string.format, string.gmatch, string.
local concat, insert, remove = table.concat, table.insert, table.remove
local apply = structure.processors.apply
local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
+local lpegmatch = lpeg.match
local variables = interfaces.variables
@@ -59,7 +60,7 @@ local one_keys = {
sb = "line", db = "line", tb = "line",
ep = "line", es = "line", ed = "line", et = "line",
sd = "line", ldd = "line", rdd = "line",
- hb = "line", bb = "line", oe = "line",
+ hb = "line", bb = "line", oe = "line", bd = "line", bw = "line",
z = "text", cz = "text", zt = "text", zn = "number",
zbt = "text", zbn = "number", ztt = "text", ztn = "number",
mov = "transform", sub = "transform", dir = "transform", off = "transform",
@@ -141,10 +142,11 @@ local syntax = {
local definitions = { }
function chemicals.undefine(name)
- definitions[name] = nil
+ definitions[lower(name)] = nil
end
function chemicals.define(name,spec,text)
+ name = lower(name)
local dn = definitions[name]
if not dn then dn = { } definitions[name] = dn end
dn[#dn+1] = {
@@ -154,7 +156,7 @@ function chemicals.define(name,spec,text)
end
local metacode, kind, keys, bonds, max, txt, textsize, rot, pstack
-local molecule = chemicals.molecule -- or use chemicals.moleculeparser:match(...)
+local molecule = chemicals.molecule -- or use lpegmatch(chemicals.moleculeparser,...)
local function fetch(txt)
local st = stack[txt]
@@ -197,12 +199,12 @@ local pattern =
lpeg.Cc(false) * lpeg.Cc(false) * lpeg.Cc(false) * text
)
---~ local n, operation, index, upto, set, text = pattern:match("RZ1357")
+--~ local n, operation, index, upto, set, text = lpegmatch(pattern,"RZ1357")
---~ print(pattern:match("RZ=x")) 1 RZ false false false x
---~ print(pattern:match("RZ1=x")) 1 RZ 1 false false x
---~ print(pattern:match("RZ1..3=x")) 1 RZ 1 3 false x
---~ print(pattern:match("RZ13=x")) 1 RZ false false table x
+--~ print(lpegmatch(pattern,"RZ=x")) 1 RZ false false false x
+--~ print(lpegmatch(pattern,"RZ1=x")) 1 RZ 1 false false x
+--~ print(lpegmatch(pattern,"RZ1..3=x")) 1 RZ 1 3 false x
+--~ print(lpegmatch(pattern,"RZ13=x")) 1 RZ false false table x
local function process(spec,text,n,rulethickness,rulecolor,offset)
insert(stack,{ spec=spec, text=text, n=n })
@@ -216,7 +218,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset)
process(di.spec,di.text,1,rulethickness,rulecolor)
end
else
- local rep, operation, special, index, upto, set, text = pattern:match(s)
+ local rep, operation, special, index, upto, set, text = lpegmatch(pattern,s)
if operation == "pb" then
insert(pstack,kind)
metacode[#metacode+1] = syntax.pb.direct
@@ -441,7 +443,7 @@ function chemicals.stop()
if trace_structure then
logs.report("chemical", "metapost code:\n%s", mpcode)
end
- metapost.graphic(chemicals.instance,chemicals.format,mpcode,"")
+ metapost.graphic(chemicals.instance,chemicals.format,mpcode)
metacode = nil
end