diff --git a/site/generate_reference.R b/site/generate_reference.R index 5b90c41fae..2a4cbb64ce 100644 --- a/site/generate_reference.R +++ b/site/generate_reference.R @@ -3,6 +3,7 @@ library(tools) library(xml2) +library(data.table) # Create reference directory ref_dir = "site/reference" @@ -48,8 +49,23 @@ for (rd_file in rd_files) { out_file = file.path(ref_dir, paste0(info$name, ".html")) temp_html = tempfile(fileext = ".html") - Rd2HTML(rd_file, out = temp_html, package = "data.table", Links = topic_links, Links2 = character()) - html_root = read_html(temp_html) + Rd2HTML(rd_file, out = temp_html, package = "data.table", Links = topic_links, Links2 = character(), Rhtml = TRUE) + + # The blocks are unsafe to parse as HTML, as an --> inside R code would terminate the comment. + env = new.env() + html_text = readLines(temp_html) + begin.rcode = which(startsWith(html_text, "") + stopifnot(length(begin.rcode) == length(end.rcode), begin.rcode < end.rcode) + for (i in seq_along(begin.rcode)) { + text = html_text[begin.rcode[i]:end.rcode[i]] + text[1] = sub('^