From 44d8cfd7f075e99c4adf6785920bcb39e9d88e75 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 11 Feb 2010 15:41:00 +0100 Subject: beta 2010.02.11 15:41 --- tex/context/base/strc-not.lua | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'tex/context/base/strc-not.lua') diff --git a/tex/context/base/strc-not.lua b/tex/context/base/strc-not.lua index 97e1ffe72..be883af57 100644 --- a/tex/context/base/strc-not.lua +++ b/tex/context/base/strc-not.lua @@ -91,6 +91,9 @@ end function notes.save(tag,newkind) local state = notestates[tag] if state and not state.saved then + if trace_notes then + logs.report("notes","saving state of %s: %s -> %s",tag,state.kind,newkind or state.kind) + end state.saved = notedata[tag] state.savedkind = state.kind state.kind = newkind or state.kind @@ -98,11 +101,14 @@ function notes.save(tag,newkind) end end -function notes.restore(tag) +function notes.restore(tag,forcedstate) local state = notestates[tag] if state and state.saved then + if trace_notes then + logs.report("notes","restoring state of %s: %s -> %s",tag,state.kind,state.savedkind) + end state.saved = nil - state.kind = state.savedkind + state.kind = forcedstate or state.savedkind notedata[tag] = state.saved end end @@ -264,9 +270,9 @@ function notes.flush(tag,whatkind) -- store and postpone local state = notestates[tag] local kind = state.kind if kind == whatkind then + local nd = notedata[tag] + local ns = state.start -- first index if kind == "postpone" then - local nd = notedata[tag] - local ns = state.start -- first index if nd and ns then if trace_notes then logs.report("notes","flushing state %s of %s from %s to %s",whatkind,tag,ns,#nd) @@ -278,17 +284,22 @@ function notes.flush(tag,whatkind) -- store and postpone state.start = nil state.kind = "insert" elseif kind == "store" then - local nd = notedata[tag] - local ns = state.start -- first index - if trace_notes then - logs.report("notes","flushing state %s of %s from %s to %s",whatkind,tag,ns,#nd) - end if nd and ns then + if trace_notes then + logs.report("notes","flushing state %s of %s from %s to %s",whatkind,tag,ns,#nd) + end for i=ns,#nd do texsprint(ctxcatcodes,format("\\handlenoteitself{%s}{%s}",tag,i)) end end state.start = nil + elseif kind == "reset" then + if nd and ns then + if trace_notes then + logs.report("notes","flushing state %s of %s from %s to %s",whatkind,tag,ns,#nd) + end + end + state.start = nil elseif trace_notes then logs.report("notes","not flushing state %s of %s",whatkind,tag) end -- cgit v1.2.3