Capping machinery

Match the closing operation to the package, then define a trial that covers the whole line.