Skip to content

HTML5 fixes #1290

@hadley

Description

@hadley

From Kurt Hornik

  • the (new) warnings about " attribute "align" not allowed for
    HTML5" are typically from roxygen2 doing

    ./R/object-defaults.R:    fig <- "\\if{html}{\\figure{logo.png}{options: align='right' alt='logo' width='120'}}"
    

    This can easily be fixed by changing align='right' to

    style='text-align: right;'
    
  • another group of problems is from putting R code in examples into a
    div. One test case is keras/man/timeseries_dataset_from_array.Rd
    which has

    Consider an array \code{data} of scalar values, of shape \code{(steps)}.
    To generate a dataset that uses the past 10
    timesteps to predict the next timestep, you would use:\if{html}{\out{<div class="sourceCode R">}}\preformatted{steps <- 100
    

    which does not work "as intended", as \preformatted will add a </p> to
    close the preceding paragraph but after the inserted <div>.

    Afaict, we don't have a way to force closing a paragraph other than
    adding an empty line, so changing the generated Rd to

    Consider an array \code{data} of scalar values, of shape \code{(steps)}.
    To generate a dataset that uses the past 10
    timesteps to predict the next timestep, you would use:\if{html}{
    
    \out{<div class="sourceCode R">}}\preformatted{steps <- 100
    

    will "work" (and also not add an extra line in the LaTeX version):
    could you please change roxygen2 accordingly?

  • Finally, most warnings are from generating methods lists for R6
    classes. E.g., for webmockr/man/Adapter.Rd we get inherited methods
    entries like

     <li> <span class="pkg-link" data-pkg="webmockr" data-topic="Adapter" data-id="disable"><p><a href="../../webmockr/html/Adapter.html%23method-disable"><code>webmockr::Adapter$disable()</code></a></span>
     </p>
     </li>

    where the span starts outside the p but is closed inside the p.

    I don't see a "simple" fix for this, but the code in rd-r6.R is

    c("\\if{html}{",
      paste0("\\out{", details, "}"),
      "\\itemize{",
      sprintf(
        paste0(
          "\\item \\out{<span class=\"pkg-link\" data-pkg=\"%s\" ",
          "data-topic=\"%s\" data-id=\"%s\">}",
          "\\href{../../%s/html/%s.html#method-%s}{\\code{%s::%s$%s()}}",
          "\\out{</span>}"
        ),
        super_meth$package,
        super_meth$classname,
        super_meth$name,
        super_meth$package,
        super_meth$classname,
        super_meth$name,
        super_meth$package,
        super_meth$classname,
        super_meth$name
      ),
      "}",
      "\\out{</details>}",
      "}"
      )
    }
    

    so perhaps instead of calling \href (which will start the p inside the
    span) you could simply \out the a hyperlink directly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions