Description of problem: I recently wrote some simple bash scripts that allow me to get/put topics via the REST interface (allowing them to be edited in my local editor). This works pretty well so far, but I have noticed when saving topics using the REST API newlines inside <screen> and <programlisting> tags are lost. When I go into skynet itself and put the newlines back in and save the topic the newlines are saved correctly. As a result I think either: - I'm doing something wrong in the way I am formatting the PUT request, this would be my first assumption except that it only appears to impact newlines in these specific elements while I treat all text the same in my script. or; - the REST API is removing the newlines when processing/saving. I'll post a follow up link as a private comment linking my script(s) but essentially the way I escape the XML string before sending it to the API is covered in my stackoverflow answer [1]. The replacement for newlines is: JSON_TOPIC_RAW=${JSON_TOPIC_RAW//^@/\\\n} # \n (newline) Where ^@ is VIM's representation of the newline control character. [1] http://stackoverflow.com/questions/10053678/escaping-characters-in-bash-for-json/11495576#11495576
Created attachment 599658 [details] Fixed Put Script
I had a look at this and the issue is in the skynet-put.sh script. You aren't currently escaping the '\n' character as it is in byte form and as such it is removed from the push. I'm not 100% sure on this but I believe the '@' is only displayed during runtime (to give a visual representation of where new lines are) and is never saved to the file. The only reason the other elements have the new lines is because of the formatting done by Skynet. However Skynet will preserve the contents of screen, programlisting and a couple other verbatim Docbook XML elements. I've attached a corrected script that preserves the '\n' character (I also left the '@' replacement in to be sure).
THe ^@ isn't saved to file, the control character it represents is. Control characters are by definition non-displayable.