Make the legend code a bit more tractable.

Expand nested list comprehension; only send legend translation variables
to pandoc when we’re rendering markdown (and not when we’re rendering
menus).

Refs #52.