Ver a proveniência

fix up edges to what markdeep expects...

main
John-Mark Gurney há 4 anos
ascendente
cometimento
dcfc594f38
1 ficheiros alterados com 44 adições e 1 eliminações
  1. +44
    -1
      box.sh

+ 44
- 1
box.sh Ver ficheiro

@@ -13,16 +13,59 @@ function printtop () {
printf("%s\n", blank)
}

function printline(a)
{
printf("* %s%*s *\n", a, maxlength - length(a), "")
}

# return the string a, with the character at pos, replaced with chr
function replace(a, pos, chr)
{
return substr(a, 1, pos - 1) chr substr(a, pos + 1)
}

output == 1 && FNR == 1 {
printtop()
printf("* %*s *\n", maxlength, "")

prevline = $0
next
}

output == 1 {
printf("* %s%*s *\n", $0, maxlength - length, "")
# fix up horizontal issues
gsub("\\|-", "+-", prevline)
gsub("\\| -", "+--", prevline)
gsub("-\\|", "-+", prevline)
gsub("- \\|", "--+", prevline)

# Fix up vertical issues

# first fix edges from below
r = split($0, a, "|")
pos = 0
for (i = 2; i <= r; i++) {
pos += length(a[i - 1]) + 1
if (substr(prevline, pos, 1) == "-")
prevline = replace(prevline, pos, "+")
}

# fix edges from above
r = split(prevline, a, "|")
pos = 0
for (i = 2; i <= r; i++) {
pos += length(a[i - 1]) + 1
if (substr($0, pos, 1) == "-")
$0 = replace($0, pos, "+")
}

printline(prevline)

prevline = $0
}

END {
printline(prevline)
printf("* %*s *\n", maxlength, "")
printtop()
}


Carregando…
Cancelar
Guardar