How to maintain white space?

I’m experimenting with a very simple code editor that uses a Lua CGI backend. I hope to edit Lua files in the editor. In previous experiments, one using a simple text area, a second using another in-browser editor, I can load and save files, but on save all the line breaks, tabs, etc, are removed and everything is URLEncoded, so when I open a saved file again, it displays as one URLEncoded line. Is there a way to maintain all the white space in the saved file with CodeMirror?