I have a simple table with a link in it. I am using gt because it does some formatting nicely, which is not shown, because it is not relevant to my question.
I wish to save the gt table as html with no \<html> tag so that it can be inserted into another html page.
And here is the
raw_html_tbl as viewed in a web browser saved using either the
writeLines method or the
cat method as shown in the script.
The HTML table in the browser seems to have added a line return, hence the need for the scroll bar.
How can I save the raw html file so that the scroll bar does not appear and the height of "This is a link" remains one line?
library(gt) library(tibble) df <- tibble( note = c("This is a <a href = https://www.cnn.com>link</a>.") ) gt_tbl <- gt(df) |> tab_options( table.width = 450 ) |> fmt_markdown(columns = note) gt_tbl raw_html_tbl <- gt_tbl |> as_raw_html() writeLines(text = raw_html_tbl, con = "test/test_tbl.html") cat(raw_html_tbl, file = "test/test_tbl.html")