SCM

[#5879] Make xtable with type = 'html' compatible with HTML5

View Trackers | Feature Requests | Download .csv | Monitor

Date:
2014-08-17 09:47
Priority:
3
State:
Open
Submitted by:
David Scott (dscott)
Assigned to:
David Scott (dscott)
Product:
None
Operating System:
None
Component:
None
 
Summary:
Make xtable with type = 'html' compatible with HTML5

Detailed description
On Thu, Aug 7, 2014 at 2:38 PM, Kurt Hornik <Kurt.Hornik@wu.ac.at> wrote:

Dear Charles,

(as xtable maintainer: I am also taking the liberty of cc'ing David as
the original author)

I have recently been looking at programmatically using HTML validation
tools on CRAN HTML content (more precisely, using the package
W3CMarkupValidator which I very recently put on CRAN with a local W3C
Markup Validation service).

This finds several problems in HTML vignette outputs generated from .Rmd
using knitr. Many of these are user errors (bad markup), but we (in
fact, Yihui [cc]) have been able to trace some of the errors found by
the validators to using print.xtable(type = "html").

One such example is the compare_lme4 vignette in package BayesFactor:
this has

```{r results='asis'}
print(xtable(cbind("lmer fixed effects"=names(lmerEff))), type='html')
```

resulting in

<!-- html table generated in R 3.0.2 by xtable 1.7-1 package -->

<!-- Sat Feb 22 14:26:26 2014 -->

<TABLE border=1>
<TR> <TH> </TH> <TH> lmer fixed effects </TH> </TR>
<TR> <TD align="right"> 1 </TD> <TD> (Intercept) </TD> </TR>
<TR> <TD align="right"> 2 </TD> <TD> Conditionheid </TD> </TR>
<TR> <TD align="right"> 3 </TD> <TD> ResponseToPrimeincorrect </TD> </TR>
<TR> <TD align="right"> 4 </TD> <TD> lRTmin1 </TD> </TR>
<TR> <TD align="right"> 5 </TD> <TD> RTtoPrime </TD> </TR>
<TR> <TD align="right"> 6 </TD> <TD> BaseFrequency </TD> </TR>
<TR> <TD align="right"> 7 </TD> <TD> ResponseToPrimeincorrect:RTtoPrime </TD> </TR>
</TABLE>

with validation errors

507 16 The border attribute on the table element is obsolete. Use CSS instead.
509 25 The align attribute on the td element is obsolete. Use CSS instead.

etc.

Fixing this would be simple: you'd need

<td style="text-align: right;">

and (I guess)

<table style="border: 1px;">

instead.

There may be other/similar issues with attributes that should nowadays
all be done via style.

Now, e.g. within knitr Yihue arranges to call pandoc to produce HTML5
output so there are no issues with the case of the HTML elements.
However, if someone else wanted to (programmatically) include the
print.xtable output in an XHTML document, there would be a problem with
using upper case elements.

You seem to be producing the necessary closing tags anyway, so perhaps
you could also switch to lower case element names?

Followup

No Followups Have Been Posted

Attached Files:

Changes:

No Changes Have Been Made to This Item

Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge