diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-05-14 19:58:50 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-05-14 19:58:50 +0200 |
commit | fd0c4577a4b6e85ca2db664906e1a03807ce133f (patch) | |
tree | fa23fcc04248d03ff82e34634b8ef1bb9cf28acb /tex/context/base/mkiv/buff-par.lua | |
parent | db581096187dc2d3cbdbe4cdc39d247c168b1607 (diff) | |
download | context-fd0c4577a4b6e85ca2db664906e1a03807ce133f.tar.gz |
2017-05-14 19:15:00
Diffstat (limited to 'tex/context/base/mkiv/buff-par.lua')
-rw-r--r-- | tex/context/base/mkiv/buff-par.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tex/context/base/mkiv/buff-par.lua b/tex/context/base/mkiv/buff-par.lua index 58ea9ab9d..9c75b90e7 100644 --- a/tex/context/base/mkiv/buff-par.lua +++ b/tex/context/base/mkiv/buff-par.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['buff-par'] = { license = "see context related readme files" } -local insert, remove, find, gmatch = table.insert, table.remove, string.find, string.gmatch +local insert, remove, find, gmatch, match = table.insert, table.remove, string.find, string.gmatch, string.match local fullstrip, formatters = string.fullstrip, string.formatters local trace_parallel = false trackers.register("buffers.parallel", function(v) trace_parallel = v end) @@ -90,18 +90,31 @@ function parallel.save(category,tag,content,frombuffer) -- use lpeg if find(content,"%s*%[") then local done = false - for label, content in gmatch(content,"%s*%[(.-)%]%s*([^%[]+)") do + + local function flush(content,label) if done then line = { } insert(lines,line) else done = true end + line.content = fullstrip(content) + line.label = label + end + + + local leading, rest = match(content,"^%s*([^%[]+)(.*)$") + if leading then + if leading ~= "" then + flush(leading) + end + content = rest + end + for label, content in gmatch(content,"%s*%[(.-)%]%s*([^%[]+)") do if trace_parallel and label ~= "" then report_parallel("reference found of category %a, tag %a, label %a",category,tag,label) end - line.content = fullstrip(content) - line.label = label + flush(content,label) end else line.content = fullstrip(content) |