I answered my own question but cannot get the answer formatted correctly. There are two issues. For one, I wish to enter a script as part of my numbered list (directly under #6). However, I am unable to get it formatted as code, unless I enter the "period" on the line directly before the script starts. If you edit the answer, and remove the period, the script is no longer formatted as code, even though each line is preceded by 4 spaces.
Secondly, after the code, I wish to continue the numbered list (to #7). However if I edit the question and enter a "7." after the code block (and before "Save the script...") its automatically converted into a "1." as if I am starting a new list.
What am I doing wrong, and how can I avoid such formatting issues in the future?