Fixed a bug caused by readLines
diff --git a/R/kableExtra-package.R b/R/kableExtra-package.R
index 4b89362..6dd0514 100644
--- a/R/kableExtra-package.R
+++ b/R/kableExtra-package.R
@@ -61,7 +61,7 @@
#' @importFrom rmarkdown latex_dependency
#' @importFrom magrittr %>%
#' @importFrom utils read.csv
-#' @importFrom readr read_lines
+#' @importFrom readr read_lines read_file
#' @name kableExtra-package
#' @aliases kableExtra
#' @docType package
diff --git a/R/util.R b/R/util.R
index 40dab5e..87f72c8 100644
--- a/R/util.R
+++ b/R/util.R
@@ -74,8 +74,7 @@
as_kable_xml <- function(x) {
tmp <- tempfile(fileext = ".xml")
write_xml(x, tmp, options = "no_declaration")
- out <- readLines(tmp, warn = FALSE)
- out <- paste(out, collapse = "\n")
+ out <- read_file(tmp)
out <- structure(out, format = "html", class = "knitr_kable")
return(out)
}
diff --git a/docs/awesome_table_in_html.html b/docs/awesome_table_in_html.html
index fdc2094..0b49116 100644
--- a/docs/awesome_table_in_html.html
+++ b/docs/awesome_table_in_html.html
@@ -11,7 +11,7 @@
<meta name="author" content="Hao Zhu" />
-<meta name="date" content="2017-07-03" />
+<meta name="date" content="2017-07-24" />
<title>Create Awesome HTML Table with knitr::kable and kableExtra</title>
@@ -217,7 +217,7 @@
<h1 class="title toc-ignore">Create Awesome HTML Table with knitr::kable and kableExtra</h1>
<h4 class="author"><em>Hao Zhu</em></h4>
-<h4 class="date"><em>2017-07-03</em></h4>
+<h4 class="date"><em>2017-07-24</em></h4>
</div>
@@ -399,7 +399,6 @@
<p>When used on a HTML table, <code>kable_styling()</code> will automatically apply twitter bootstrap theme to the table. Now it should looks the same as the original pandoc output (the one when you don’t specify <code>format</code> in <code>kable()</code>) but this time, you are controlling it.</p>
<pre class="r"><code>kable(dt) %>%
kable_styling()</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -554,7 +553,6 @@
<p>For example, to add striped lines (alternative row colors) to your table and you want to highlight the hovered row, you can simply type:</p>
<pre class="r"><code>kable(dt) %>%
kable_styling(bootstrap_options = c("striped", "hover"))</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped table-hover" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -701,7 +699,6 @@
<p>The option <code>condensed</code> can also be handy in many cases when you don’t want your table to be too large. It has slightly shorter row height.</p>
<pre class="r"><code>kable(dt) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"))</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped table-hover table-condensed" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -848,7 +845,6 @@
<p>Tables with option <code>responsive</code> looks the same with others on a large screen. However, on a small screen like phone, they are horizontally scrollable. Please resize your window to see the result.</p>
<pre class="r"><code>kable(dt) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped table-hover table-condensed table-responsive" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -998,7 +994,6 @@
<p>By default, a bootstrap table takes 100% of the width. It is supposed to use together with its grid system to scale the table properly. However, when you are writing a rmarkdown document, you probably don’t want to write your own css/or grid. For some small tables with only few columns, a page wide table looks awful. To make it easier, you can specify whether you want the table to have <code>full_width</code> or not in <code>kable_styling</code>. By default, <code>full_width</code> is set to be <code>TRUE</code> for HTML tables (note that for LaTeX, the default is <code>FALSE</code> since I don’t want to change the “common” looks unless you specified it.)</p>
<pre class="r"><code>kable(dt) %>%
kable_styling(bootstrap_options = "striped", full_width = F)</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -1148,7 +1143,6 @@
<p>Table Position only matters when the table doesn’t have <code>full_width</code>. You can choose to align the table to <code>center</code>, <code>left</code> or <code>right</code> side of the page</p>
<pre class="r"><code>kable(dt) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="width: auto !important; text-align: right;">
<thead>
<tr>
@@ -1295,7 +1289,6 @@
<p>Becides these three common options, you can also wrap text around the table using the <code>float-left</code> or <code>float-right</code> options.</p>
<pre class="r"><code>kable(dt) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "float_right")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="width: auto !important; float: right; margin-left: 10px;">
<thead>
<tr>
@@ -1446,7 +1439,6 @@
<p>If one of your tables is huge and you want to use a smaller font size for that specific table, you can use the <code>font_size</code> option.</p>
<pre class="r"><code>kable(dt) %>%
kable_styling(bootstrap_options = "striped", font_size = 7)</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="font-size: 7px; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -1598,7 +1590,6 @@
<pre class="r"><code>kable(dt) %>%
kable_styling("striped") %>%
add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 2, "Group 3" = 2))</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -1766,7 +1757,6 @@
add_header_above(c(" ", "Group 1" = 2, "Group 2" = 2, "Group 3" = 2)) %>%
add_header_above(c(" ", "Group 4" = 4, "Group 5" = 2)) %>%
add_header_above(c(" ", "Group 6" = 6))</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped table-bordered" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -1960,7 +1950,6 @@
<pre class="r"><code>kable(dt) %>%
kable_styling("striped") %>%
add_footnote(c("Footnote 1", "Have a good day."), notation = "alphabet")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -2103,18 +2092,6 @@
</td>
</tr>
</tbody>
-<tfoot>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>a</sup> Footnote 1
-</td>
-</tr>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>b</sup> Have a good day.
-</td>
-</tr>
-</tfoot>
</table>
</div>
<div id="number" class="section level3">
@@ -2122,7 +2099,6 @@
<pre class="r"><code>kable(dt) %>%
kable_styling("striped") %>%
add_footnote(c("Footnote 1", "Have a good day."), notation = "number")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -2265,18 +2241,6 @@
</td>
</tr>
</tbody>
-<tfoot>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>1</sup> Footnote 1
-</td>
-</tr>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>2</sup> Have a good day.
-</td>
-</tr>
-</tfoot>
</table>
</div>
<div id="symbol" class="section level3">
@@ -2284,7 +2248,6 @@
<pre class="r"><code>kable(dt) %>%
kable_styling("striped") %>%
add_footnote(c("Footnote 1", "Footnote 2", "Footnote 3"), notation = "symbol")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -2427,23 +2390,6 @@
</td>
</tr>
</tbody>
-<tfoot>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>*</sup> Footnote 1
-</td>
-</tr>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>†</sup> Footnote 2
-</td>
-</tr>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>‡</sup> Footnote 3
-</td>
-</tr>
-</tfoot>
</table>
</div>
</div>
@@ -2457,7 +2403,6 @@
"Group 1 contains mpg, cyl and disp",
"Group 2 contains hp, drat and wt"),
notation = "symbol")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="margin-left: auto; margin-right: auto;">
<caption>
Demo Table<sup>*</sup>
@@ -2616,23 +2561,6 @@
</td>
</tr>
</tbody>
-<tfoot>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>*</sup> This table is from mtcars
-</td>
-</tr>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>†</sup> Group 1 contains mpg, cyl and disp
-</td>
-</tr>
-<tr>
-<td style="padding: 0; border:0;" colspan="100%">
-<sup>‡</sup> Group 2 contains hp, drat and wt
-</td>
-</tr>
-</tfoot>
</table>
<hr />
<p>The following features are introduced in <code>kableExtra</code> 0.2.0.</p>
@@ -2645,7 +2573,6 @@
kable_styling("striped", full_width = F) %>%
group_rows("Group 1", 4, 7) %>%
group_rows("Group 2", 8, 10)</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<caption>
Group Rows
@@ -2921,7 +2848,6 @@
<pre class="r"><code>kable(dt) %>%
kable_styling("striped", full_width = F) %>%
group_rows("Group 1", 3, 5, label_row_css = "background-color: #666; color: #fff;")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -3077,7 +3003,6 @@
<pre class="r"><code>kable(dt) %>%
kable_styling("striped", full_width = F) %>%
add_indent(c(1, 3, 5))</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -3241,7 +3166,6 @@
kable_styling(full_width = F) %>%
column_spec(1, bold = T) %>%
column_spec(2, width = "30em")</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -3290,7 +3214,6 @@
kable_styling("striped", full_width = F) %>%
column_spec(7, bold = T) %>%
row_spec(5, bold = T)</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -3446,7 +3369,6 @@
kable_styling(full_width = F) %>%
column_spec(1, bold=T) %>%
collapse_rows(columns = 1:2)</code></pre>
-<?xml version="1.0" encoding="UTF-8" ?>
<table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
@@ -3476,7 +3398,7 @@
1
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3484,7 +3406,7 @@
2
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3500,7 +3422,7 @@
4
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3516,7 +3438,7 @@
6
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
@@ -3524,7 +3446,7 @@
7
</td>
<td style="text-align:center;">
-0
+1
</td>
</tr>
<tr>
diff --git a/inst/NEWS b/inst/NEWS
index 6afcaac..7554c8c 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -1,3 +1,25 @@
+kableExtra 0.3.0.9000
+--------------------------------------------------------------------------------
+* Add scroll_box for HTML table for extremely long/wide tables
+
+* Fixed a bug in collapse_row on removing addlinespace
+
+* Removed addlinespace from group_rows
+
+* Added monospace to column_spec
+
+* Lowered R version requirement to R 3.1.0
+
+* Added testthat
+
+* For all HTML table functions, changed reading method from `xml2::read_xml` to
+`xml2::read_html` plus some extra steps to avoid errors when HTML contents
+don't fulfill XHTML requirements
+
+* For all HTML table functions, improved exportation method to remove the XML
+declaration.
+
+
kableExtra 0.3.0
--------------------------------------------------------------------------------
* Improved the look of HTML grouped header row (again) by adding spaces between