Saturday, November 4, 2017

Confessions of a dumb blogger- III


Instead of the “clean” HTML as in my last post, what if I knit the .Rmd document to get the standard output? I tried that and then opened the result in Chrome browser. I got a beautifully formatted page.


Can blogger handle this HTML file?

To test that I opened this file in Chrome and viewed and copied its page source. In Blogger I pasted the source code into the HTML sheet. The preview showed the above post, but it didn't appear right. If you know HTML programming, you may be able to edit it, but I guess there will be quite some work to do!

First, let's look at the page source in Chrome. For the benefit of myself and my fellow dummies I exported the page source to pdf format in letter page size. It was a staggering 122 pages with only the last three pages contain the information we want to display.


So, Kyle was right: the HTML file that R produces is probably going to be swarmed with hundreds (or, gasp, thousands) of lines of disgusting Javascript”.

On the other hand, Kyle was talking about rendering RMarkdown files to HTML for blogging. I guess that the judgment “disgusting” is only relative, and if only we were to be working for reproducible research these would turn into lines of “lovely” Javascript. But that's another matter.

For our purpose if we could remove the superfluous matter from this source file manually, we might get the slim HTML source we want to get. So I tried using Notepad++ for editing the HTML page.

Here's what you see when the HTML file is opened in Notepad++.


Here I could try deleting what looks like superfluous matter (remember I have zero knowledge of HTML) so that I would get “clean” HTML. Then I could open it in Chrome (or other browser) via the “Run” menu. If it is not right I could undelete and try again.

And then through trial and error I finally ended up with exactly the same “clean” HTML as with Kyle's approach (see my last post). Well, that's not surprising at all because Kyle's approach is just the programmatic way of doing what I've done manually, with the added benefit of having no room for error!



No comments:

Post a Comment