From 31a17b45895a62d56fab21b91ea2b3f29f840f92 Mon Sep 17 00:00:00 2001 From: Colin Fay <contact@colinfay.me> Date: Fri, 2 Oct 2020 12:19:37 +0200 Subject: [PATCH] Allow to set the lang attribute, will close #82 --- R/html_print.R | 5 +++-- man/save_html.Rd | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/R/html_print.R b/R/html_print.R index 8a0e4900..a0699ff3 100644 --- a/R/html_print.R +++ b/R/html_print.R @@ -66,9 +66,10 @@ html_print <- function(html, background = "white", viewer = getOption("viewer", #' @param background Background color for web page #' @param file File to write content to #' @param libdir Directory to copy dependencies to +#' @param lang Value of the `<html>` `lang` attribute #' #' @export -save_html <- function(html, file, background = "white", libdir = "lib") { +save_html <- function(html, file, background = "white", libdir = "lib", lang = "en") { force(html) force(background) force(libdir) @@ -96,7 +97,7 @@ save_html <- function(html, file, background = "white", libdir = "lib") { # build the web-page html <- c("<!DOCTYPE html>", - "<html>", + sprintf('<html lang="%s">', lang), "<head>", "<meta charset=\"utf-8\"/>", sprintf("<style>body{background-color:%s;}</style>", htmlEscape(background)), diff --git a/man/save_html.Rd b/man/save_html.Rd index 1dfeaf59..5fc920b3 100644 --- a/man/save_html.Rd +++ b/man/save_html.Rd @@ -4,7 +4,7 @@ \alias{save_html} \title{Save an HTML object to a file} \usage{ -save_html(html, file, background = "white", libdir = "lib") +save_html(html, file, background = "white", libdir = "lib", lang = "en") } \arguments{ \item{html}{HTML content to print} @@ -13,7 +13,9 @@ save_html(html, file, background = "white", libdir = "lib") \item{background}{Background color for web page} -\item{libdir}{Directory to copy dependenies to} +\item{libdir}{Directory to copy dependencies to} + +\item{lang}{Value of the `<html>` `lang` attribute} } \description{ Save the specified HTML object to a file, copying all of it's