| 1 | #!/usr/local/bin/perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | my ($title); | ||
| 5 | while(<>) { | ||
| 6 | if(0) { 1 } | ||
| 7 | elsif(/^=for +literate:command +target=/) { 1 } | ||
| 8 | elsif(/^=for +literate +target:/) { 1 } # deprecated | ||
| 9 | elsif(/^=end\h+literate/) { undef($title) } | ||
| 10 | elsif(/^=for\h+literate\h+\.\h*$/) { undef($title) } | ||
| 11 | elsif(/^=begin\h+literate\h+\+?(\H.*?)\h*$/) { $title=$1 } | ||
| 12 | elsif(/^=for\h+literate\h+\+?(\H.*?)\h*$/) { $title=$1 } | ||
| 13 | elsif($title&&/^(\h*)\S/) { print "$1< $title >=\n$_"; undef($title) } | ||
| 14 | else { print } | ||
| 15 | } | ||
| 16 |