Skip to content

Commit

Permalink
Improve HTML generation.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@82283 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
hornik committed Apr 29, 2022
1 parent 1aff12e commit 5b2011d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/library/tools/R/Rd2HTML.R
Expand Up @@ -842,7 +842,7 @@ Rd2HTML <-
switch(blocktag,
"\\value"=,
"\\arguments"= {
of1('<tr valign="top"><td>')
of1('<tr style="vertical-align: top;"><td>')
inPara <<- NA
## Argh. Quite a few packages put the items in
## their value section inside \code.
Expand Down Expand Up @@ -1074,7 +1074,7 @@ Rd2HTML <-
urlify(stylesheet),
'" />\n',
'</head><body><div class="container">\n\n',
'<table width="100%">',
'<table style="width: 100%;">',
'<tr><td>',
name)
if (nchar(package))
Expand Down
2 changes: 1 addition & 1 deletion src/library/tools/R/Vignettes.R
Expand Up @@ -1079,7 +1079,7 @@ function(pkg, con, vignetteIndex = NULL)
otherfiles)
urls <- paste0('<a href="', otherfiles, '">', otherfiles, '</a>')
html <- c(html, '<h2>Other files in the <span class="samp">doc</span> directory</h2>',
'<table width="100%">',
'<table style="width: 100%;">',
'<col style="width: 24%;" />',
'<col style="width: 50%;" />',
'<col style="width: 24%;" />',
Expand Down
6 changes: 3 additions & 3 deletions src/library/tools/R/install.R
Expand Up @@ -2893,15 +2893,15 @@ if(FALSE) {
for (f in nm) {
MM <- M[first == f, ]
if (f != " ")
cat("\n<h2><a name=\"", f, "\">-- ", f, " --</a></h2>\n\n",
cat("\n<h2><a id=\"", f, "\">-- ", f, " --</a></h2>\n\n",
sep = "", file = outcon)
writeLines(c('<table width="100%">',
writeLines(c('<table style="width: 100%;">',
paste0('<tr><td style="width: 25%;"><a href="', MM[, 2L], '.html">',
MM$HTopic, '</a></td>\n<td>', MM[, 3L],'</td></tr>'),
"</table>"), outcon)
}
} else if (nrow(M)) {
writeLines(c('<table width="100%">',
writeLines(c('<table style="width: 100%;">',
paste0('<tr><td style="width: 25%;"><a href="', M[, 2L], '.html">',
M$HTopic, '</a></td>\n<td>', M[, 3L],'</td></tr>'),
"</table>"), outcon)
Expand Down
22 changes: 11 additions & 11 deletions src/library/tools/R/toHTML.R
Expand Up @@ -68,7 +68,7 @@ function(x, ...)
result <- c(result,
paste0('<h2>', htmlify(x$title), ' in package &lsquo;',
htmlify(pkg), '&rsquo;</h2>'),
'<table cols="2" width="100%">',
'<table cols="2" style="width: 100%;">',
paste0('<tr>\n',
' <td style="text-align: left; vertical-align: top; width: 10%;">\n',
htmlify(out[[pkg]][, "Item"]),
Expand Down Expand Up @@ -184,7 +184,7 @@ function(x, ...)
# is depth 3

makeVignetteTable <- function(vignettes, depth=2) {
out <- c('<table width="100%">',
out <- c('<table style="width: 100%;">',
'<col style="width: 22%;" />',
'<col style="width: 2%;" />',
'<col style="width: 50%;" />',
Expand All @@ -203,13 +203,13 @@ makeVignetteTable <- function(vignettes, depth=2) {
if (nchar(Outfile)) Outfile else File, '">',
pkg, "::", topic, '</a>')
line <- c('<tr><td style="text-align: right; vertical-align: top;">', link,
'</td>\n<td></td><td valign="top">', Title,
'</td>\n<td valign="top">',
'</td>\n<td></td><td style="vertical-align: top;">', Title,
'</td>\n<td style="vertical-align: top;">',
if (nchar(Outfile))
c('<a href="', root, Outfile,'">', vignette_type(Outfile), '</a>'),
'</td>\n<td valign="top">',
'</td>\n<td style="vertical-align: top;">',
'<a href="', root, File,'">source</a>',
'</td>\n<td valign="top" style="white-space: nowrap">',
'</td>\n<td style="vertical-align: top; white-space: nowrap">',
if (nchar(R))
c('<a href="', root, R,'">R code</a>'),
'</td></tr>')
Expand All @@ -219,7 +219,7 @@ makeVignetteTable <- function(vignettes, depth=2) {
}

makeDemoTable <- function(demos, depth=2) {
out <- c('<table width="100%">',
out <- c('<table style="width: 100%;">',
'<col style="width: 22%;" />',
'<col style="width: 2%;" />',
'<col style="width: 54%;" />',
Expand All @@ -242,16 +242,16 @@ makeDemoTable <- function(demos, depth=2) {
runlink <- ""
}
line <- c('<tr><td style="text-align: right; vertical-align: top;">', link,
'</td>\n<td></td><td valign="top">', Title,
'</td>\n<td valign="top" style="white-space: nowrap">', runlink,
'</td>\n<td></td><td style="vertical-align: top;">', Title,
'</td>\n<td style="vertical-align: top; white-space: nowrap">', runlink,
'</td></tr>')
out <- c(out, paste(line, collapse=''))
}
c(out, '</table>')
}

makeHelpTable <- function(help, depth=2) {
out <- c('<table width="100%">',
out <- c('<table style="width: 100%;">',
'<col style="width: 22%;" />',
'<col style="width: 2%;" />',
'<col style="width: 74%;" />')
Expand All @@ -266,7 +266,7 @@ makeHelpTable <- function(help, depth=2) {
ifelse(nchar(pkg), paste0(pkg, "::"), ""),
topic, '</a>')
lines <- paste0('<tr><td style="text-align: right; vertical-align: top;">', links,
'</td>\n<td></td><td valign="top">', Title,
'</td>\n<td></td><td style="vertical-align: top;">', Title,
'</td></tr>')
c(out, lines, '</table>')
}
Expand Down
8 changes: 4 additions & 4 deletions src/library/utils/R/help.R
Expand Up @@ -121,14 +121,14 @@ print.help_files_with_topic <- function(x, ...)
'<link rel="stylesheet" type="text/css" href="/doc/html/R.css" />\n',
'</head>\n<body>\n<div class="container">\n\n<hr>\n')
out <- c(out, '<p>', msg, '</p><br>')
out <- c(out, '<table width="100%">\n',
'<tr style="text-align: left;" valign="top">\n',
'<td width="25%">Package</td><td>Library</td></tr>\n')
out <- c(out, '<table style="width: 100%;">\n',
'<tr style="text-align: left; vertical-align: top;">\n',
'<td style="width: 25%;">Package</td><td>Library</td></tr>\n')
pkgs <- basename(paths)
links <- paste0('<a href="http://127.0.0.1:', port,
'/library/', pkgs, '/help/', topic, '">',
pkgs, '</a>')
out <- c(out, paste0('<tr style="text-align: left;" valign="top">\n',
out <- c(out, paste0('<tr style="text-align: left; vertical-align: top;">\n',
'<td>', links, '</td><td>',
dirname(paths), '</td></tr>\n'))
out <- c(out, "</table>\n<hr>\n</div>\n</body>\n</html>")
Expand Down
6 changes: 3 additions & 3 deletions src/library/utils/R/linkhtml.R
Expand Up @@ -113,16 +113,16 @@ make.packages.html <-
writeLines(paste0("<a href=\"#pkgs-", nm, "\">", nm, "</a>"), out)
writeLines("</p>\n", out)
}
cat('<table width="100%">\n', file = out)
cat('<table style="width: 100%;">\n', file = out)
for (a in nm) {
if(use_alpha)
cat("<tr id=\"pkgs-", a, "\"> <td></td>\n", sep = "", file = out)
for (i in pg[first == a]) {
title <- packageDescription(i, lib.loc = lib, fields = "Title",
encoding = "UTF-8")
if (is.na(title)) title <- "-- Title is missing --"
cat('<tr style="text-align: left;" valign="top" id="lib-', i, '">\n',
'<td width="25%"><a href="', lib0, '/', i,
cat('<tr style="text-align: left; vertical-align: top;" id="lib-', i, '">\n',
'<td style="width: 25%;"><a href="', lib0, '/', i,
'/html/00Index.html">', i, "</a></td><td>",
gsub("&", "&amp;", title), "</td></tr>\n",
file = out, sep = "")
Expand Down
4 changes: 2 additions & 2 deletions src/library/utils/R/mirrorAdmin.R
Expand Up @@ -31,10 +31,10 @@ function(mirrors = NULL, file = "mirrors.html",
m <- mirrors[mirrors$Country == country,]
z <- c(z, paste0("<dt>", country, "</dt>"),
"<dd>",
"<table border=0 width=\"90%\">")
"<table border=0 style=\"width: 90%;\">")
for(k in seq_len(nrow(m))) {
z <- c(z, "<tr>",
"<td width=\"45%\">",
"<td style=\"width: 45%;\">",
sprintf("<a href=\"%s\" target=\"_top\">%s</a>",
m$URL[k], m$URL[k]),
"</td>\n",
Expand Down

0 comments on commit 5b2011d

Please sign in to comment.