Last active
September 19, 2017 17:16
-
-
Save dkuppitz/023dc5cc8f392ef2b9663915cf5b1bd9 to your computer and use it in GitHub Desktop.
cat input.asciidoc | awk -f replace.awk > output.asciidoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BEGIN { | |
| last = -1 | |
| chars[1] = "=" | |
| chars[2] = "-" | |
| chars[3] = "~" | |
| chars[4] = "^" | |
| chars[5] = "+" | |
| } | |
| { if (last != -1) { | |
| l = length($0) | |
| if (l > 0 && l == length(last)) { | |
| pl = 1 | |
| for (i in chars) { | |
| h = sprintf("%" l "s", "") ; gsub(/ /, chars[i], h) | |
| if ($0 == h) { | |
| prefix = sprintf("%" i "s", "") ; gsub(/ /, "=", prefix) | |
| last = prefix " " last | |
| pl = 0 | |
| break | |
| } | |
| } | |
| if (pl) print last | |
| } else { | |
| print last | |
| last = $0 | |
| } | |
| } else last = $0 | |
| } | |
| END { | |
| print last | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment