render xml table out
diff --git a/docs/kableExtra_and_xml2.Rmd b/docs/kableExtra_and_xml2.Rmd
index 6304e36..9823a7c 100644
--- a/docs/kableExtra_and_xml2.Rmd
+++ b/docs/kableExtra_and_xml2.Rmd
@@ -13,11 +13,23 @@
In `kableExtra` 1.0, I exported two functions that were previously used internally in this package: `kable_as_xml` and `xml_as_kable`. Here is an example for how to use these 2 function and xml2 to hack your table and do something `kableExtra` is not capable to do (at least right now).
+<style>
+@-webkit-keyframes rotate {
+ 0% {transform: rotate(0deg)}
+ 100% {transform: rotate(360deg)}
+}
+
+.badIdea {
+ position:relative;
+ animation: rotate 3s linear infinite;
+}
+</style>
+
```{r}
library(kableExtra)
library(xml2)
-demo <- kable(mtcars[1:5, 1:5]) %>% # As always, mtcars ;)
+demo <- kable(mtcars[1:4, 1:4]) %>% # As always, mtcars ;)
kable_styling(full_width = F) %>%
kable_as_xml()
@@ -25,9 +37,29 @@
xml_child(2) %>% # Select <tbody> (1 is <thead>)
xml_child(2) %>% # Select 2nd row <tr> in <tbody>
xml_child(1) %>% # Select 1st cell in 2nd row <td>
- xml_set_attr("style", "background: red; color: white;") # Add attribute to style
+ xml_set_attr("class", "badIdea") # Add attribute to style
xml_as_kable(demo) # Render that xml back as kable
```
+> Only for illustration. Animating your texts like this is a **horrible** idea and will distract audience's attention.
+> I mean seriously, what I want to show here is `xml2`...
+
+
For those `%>%` fans, keep in mind that since `xml2` makes modification to an external xml object. Although it looks like you can put everything in one pipe, the reality is that you will have to save the entire xml first, run the `xml2` code and then get it rendered.
+
+***
+
+Note:
+Here is my simple rotation css. You need to put them in rmarkdown to get things work.
+```{css, eval = F}
+@-webkit-keyframes rotate {
+ 0% {transform: rotate(0deg)}
+ 100% {transform: rotate(360deg)}
+}
+
+.badIdea {
+ position:relative;
+ animation: rotate 3s linear infinite;
+}
+```