He was appointed to the chair again in 1836 and held it until 1866 when he was to resign for a second time again on a matter of principle

Can you repeat this sentence, but add in punctuation?
He was appointed to the chair again in 1836 and held it until 1866 when he was to resign for a second time, again on a matter of principle.