code reformatting & adaptation for codemirror