5899bbf0486994df79dbb6473cd3805a6aa50898
fix-code.sed
... | ... | @@ -2,21 +2,27 @@ |
2 | 2 | # Convert unlabelled code |
3 | 3 | # |
4 | 4 | |
5 | -# Code output by action=markdown ends with two spaces (mostly). |
|
6 | -/ $/,/\[Get Code]/ { |
|
7 | - # At the end of the block dump the accumulated lines |
|
8 | - /\[Get Code\]/ { |
|
5 | +# Code output by action=markdown (mostly) ends with two spaces. |
|
6 | +# Beginning with non-whitespace and ending with (only) two-spaces. |
|
7 | +/^\S.*\S $/,/\[Get Code]/ { |
|
8 | + # Handle no terminating 'Get Code' |
|
9 | + $ { |
|
9 | 10 | x |
10 | 11 | p |
12 | + d |
|
13 | + } |
|
14 | + # At the end of the block dump the accumulated lines |
|
15 | + /\[Get Code]/ { |
|
16 | + # clear this line to clear the hold space when exchanging |
|
17 | + s/.*// |
|
11 | 18 | x |
19 | + # indent and cleanup |
|
20 | + s/\n/\n /g |
|
21 | + s/ \n/\n/g |
|
22 | + p |
|
12 | 23 | d |
13 | 24 | } |
14 | 25 | |
15 | - # clean whitespace |
|
16 | - s/\s\+$// |
|
17 | - # indent |
|
18 | - s/^/ / |
|
19 | - |
|
20 | 26 | # accumulate lines within the code block |
21 | 27 | H |
22 | 28 | d |