Measurement of quarkonium production in proton–lead and proton–proton collisions at 5.02TeV with the ATLAS detector