The popularity of Napoleon III the French emperor had declined and he decided that a war with Prussia might change his political fortunes

What is the correctly punctuated version of this sentence?
The popularity of Napoleon III, the French emperor, had declined and he decided that a war with Prussia might change his political fortunes.