How to export query results as markdown or rich text?

Posted another work-around here: