- if v.kcb then
- v.kcb=string.gsub(v.kcb, "AnyModifier%+", "")
- end
- if v.action=="doc" then
- outi=outi+1
- out[outi]={doc=v.text, bindings={}}
- elseif v.submap then
- parsetable(v.submap, prefix..v.kcb.." ")
- else
- assert(out[outi])
- v.kcb=prefix..v.kcb
- table.insert(out[outi].bindings, v)
+ if not v.invalid then
+ if v.kcb then
+ v.kcb=string.gsub(v.kcb, "AnyModifier%+", "")
+ end
+ if v.action=="doc" then
+ if outi==0 or #out[outi].bindings>0 then
+ outi=outi+1
+ end
+ out[outi]={doc=v.text, bindings={}}
+ elseif v.submap then
+ parsetable(v.submap, prefix..v.kcb.." ")
+ else
+ assert(out[outi])
+ v.kcb=prefix..v.kcb
+ table.insert(out[outi].bindings, v)
+ end