This comes from discussion on PR #230
For the formatting rule, let's imitate GAPDoc: After finding a @BeginCode, we record whatever came before it on the line as a PREFIX. Then in all subsequent lines, we take the maximal common prefix of that line, and the recorded PREFIX, and remove that from the line we just read, and store/process the rest of the line; we repeat this until we encounter the matching @EndCode.
This should take care of weird indentation quirks. Of course this should be documented, and also applied to other similar constructs.