width: 16px; height: 16px; display: inline-block;

## Copyright (C) 2021  Brodie Gaslam
##
## This file is part of "fansi - ANSI Control Sequence Aware String Functions"
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 2 or 3 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## Go to <https://www.r-project.org/Licenses> for copies of the licenses.

style <- "width: 16px; height: 16px; display: inline-block;"

span <- "<span style=\"background-color: %s; %s\"></span>"

colors.8 <- fansi:::esc_color_code_to_html(rbind(c(0:7), 0L, 
    0L, 0L, 0L))

fansi:::esc_color_code_to_html(matrix(c(9L, 0L, 0L, 0L, 0L)))

Error in fansi:::esc_color_code_to_html(matrix(c(9L, 0L, 0L, 0L, 0L))) : 
  Internal Error: applying non-color.

colors.255 <- fansi:::esc_color_code_to_html(rbind(8L, 5L, 0:255, 
    0L, 0L))

colors.tru <- fansi:::esc_color_code_to_html(do.call(rbind, c(list(8L, 
    2L), expand.grid(vals, vals, vals))))

as_html_page <- function(x) {
    tmp <- tempfile()
    writeLines(c("<html><pre>", as.character(x), "</pre></html>"), 
        tmp)
    browseURL(tmp)
}

# note this will clutter temp directory, but needed so we can examine source

hello <span style='color: #BB0000; background-color: #00BB00; font-weight: bold;'>world</span>

[1] "hello <span style='color: #BB0000; background-color: #00BB00; font-weight: bold;'>world</span>"

hello <span style='color: #BB0000; background-color: #005F5F; font-weight: bold;'>world</span>

[1] "hello <span style='color: #BB0000; background-color: #005F5F; font-weight: bold;'>world</span>"

# this turned out to be a good corner case, italic is not actually
# italicized

<span style='font-weight: bold;'>bold</span> <span style='font-weight: 100;'>faint</span> italic