initial support for internal viewer for R Markdown; improve perf