summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/chem-str.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/chem-str.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/chem-str.lua35
1 files changed, 23 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/context/base/chem-str.lua b/Master/texmf-dist/tex/context/base/chem-str.lua
index 1a6ed4dc213..6e2af50fb4b 100644
--- a/Master/texmf-dist/tex/context/base/chem-str.lua
+++ b/Master/texmf-dist/tex/context/base/chem-str.lua
@@ -17,7 +17,7 @@ local report_chemistry = logs.reporter("chemistry")
local format, gmatch, match, lower, gsub = string.format, string.gmatch, string.match, string.lower, string.gsub
local concat, insert, remove = table.concat, table.insert, table.remove
-local apply = structures.processors.apply
+local processor_tostring = typesetters.processors.tostring
local lpegmatch = lpeg.match
local settings_to_array = utilities.parsers.settings_to_array
@@ -230,9 +230,9 @@ local function process(spec,text,n,rulethickness,rulecolor,offset)
m = m + 1 ; metacode[m] = syntax.pb.direct
if keys[special] == "text" and index then
if keys["c"..special] == "text" then -- can be option: auto ...
- metacode[#metacode+1] = format('chem_c%s(%s,%s,"");',special,bonds,index)
+ m = m + 1 ; metacode[m] = format('chem_c%s(%s,%s,"");',special,bonds,index)
else
- metacode[#metacode+1] = format('chem_%s(%s,%s,"");',special,bonds,index)
+ m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"");',special,bonds,index)
end
end
elseif operation == "save" then
@@ -319,7 +319,8 @@ local function process(spec,text,n,rulethickness,rulecolor,offset)
if t then
local a = align and align[si]
if a then a = "." .. a else a = "" end
- m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,a,bonds,si,molecule(apply(t)))
+ t = molecule(processor_tostring(t))
+ m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,a,bonds,si,t)
end
end
elseif upto then
@@ -329,14 +330,16 @@ local function process(spec,text,n,rulethickness,rulecolor,offset)
if t then
local s = align and align[i]
if s then s = "." .. s else s = "" end
- m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,i,molecule(apply(t)))
+ t = molecule(processor_tostring(t))
+ m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,i,t)
end
end
elseif index == 0 then
local t = text
if not t then txt, t = fetch(txt) end
if t then
- m = m + 1 ; metacode[m] = format('chem_%s_zero("\\dochemicaltext{%s}");',operation,molecule(apply(t)))
+ t = molecule(processor_tostring(t))
+ m = m + 1 ; metacode[m] = format('chem_%s_zero("\\dochemicaltext{%s}");',operation,t)
end
elseif index then
local t = text
@@ -344,7 +347,8 @@ local function process(spec,text,n,rulethickness,rulecolor,offset)
if t then
local s = align and align[index]
if s then s = "." .. s else s = "" end
- m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,index,molecule(apply(t)))
+ t = molecule(processor_tostring(t))
+ m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,index,t)
end
else
for i=1,max do
@@ -353,7 +357,8 @@ local function process(spec,text,n,rulethickness,rulecolor,offset)
if t then
local s = align and align[i]
if s then s = "." .. s else s = "" end
- m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,i,molecule(apply(t)))
+ t = molecule(processor_tostring(t))
+ m = m + 1 ; metacode[m] = format('chem_%s%s(%s,%s,"\\dochemicaltext{%s}");',operation,s,bonds,i,t)
end
end
end
@@ -388,6 +393,9 @@ function chemicals.start(settings)
local textsize, rulethickness, rulecolor = settings.size, settings.rulethickness, settings.rulecolor
local width, height, scale, offset = settings.width or 0, settings.height or 0, settings.scale or "medium", settings.offset or 0
local l, r, t, b = settings.left or 0, settings.right or 0, settings.top or 0, settings.bottom or 0
+ --
+ metacode = { "if unknown context_chem : input mp-chem.mpiv ; fi ;" } -- no format anyway
+ --
if scale == variables.small then
scale = 500
elseif scale == variables.medium or scale == 0 then
@@ -398,8 +406,8 @@ function chemicals.start(settings)
scale = tonumber(scale)
if not scale or scale == 0 then
scale = 750
- elseif scale < 500 then
- scale = 500
+ elseif scale < 10 then
+ scale = 10
end
end
if width == variables.fit then
@@ -435,16 +443,19 @@ function chemicals.start(settings)
height = false
end
scale = 0.75 * scale/625
- metacode = { format("chem_start_structure(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ;",
+ --
+ metacode[#metacode+1] = format("chem_start_structure(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ;",
chemicals.structures,
l/25, r/25, t/25, b/25, scale,
tostring(settings.axis == variables.on), tostring(width), tostring(height), tostring(offset)
- ) }
+ )
+ --
variant, keys, bonds, stack, rot, pstack = "six", { }, 6, { }, 1, { }
end
function chemicals.stop()
metacode[#metacode+1] = "chem_stop_structure ;"
+ --
local mpcode = concat(metacode,"\n")
if trace_structure then
report_chemistry("metapost code:\n%s", mpcode)