buildkite / terminal-to-html

Converts arbitrary shell output (with ANSI) into beautifully rendered HTML
http://buildkite.github.io/terminal-to-html
MIT License
649 stars 45 forks source link

ESC[m should be treated the same as ESC[0m #28

Closed lox closed 9 years ago

lox commented 9 years ago

We are using tput to handle escape codes for us, for example:

has_tty() {
  stty 2>/dev/null >/dev/null
}

ansi_header() {
  if has_tty ; then
    echo
    echo >&2 -e "$(tput sgr 0 1)$(tput bold)$(tput setaf 4)--- $@$(tput sgr0)"
  fi
}

ansi_success() {
  if has_tty ; then
    echo >&2 "$(tput setaf 2)$@ ✔$(tput sgr0)"
  fi
}

ansi_failure() {
  if has_tty ; then
    echo >&2 "$(tput setaf 1)$@ ✗$(tput sgr0)"
  fi
}

it seems that tput sgr0 outputs ESC[m, rather than the `ESC[0m'. Apparently in absence of the 0 value, 0 should be assumed.

The result of this is that our ansi styles aren't correctly reset when converted to html.