publishing knitr or Jupyter docs on web

25 views
Skip to first unread message

Bob Carpenter

unread,
Dec 30, 2015, 4:17:13 PM12/30/15
to stan...@googlegroups.com
knitr
------------

OK, I didn't realize that when I to this:

> knit("foo.Rmd")

it produces a markdown file and directory of figures:

foo.md
figure/*.png

The figures were only 100K and 40K.

The markdown can be hosted directly on GitHub. Then when
you view the file, GitHub will do the translation from
markdown (.md) to HTML.

See the second example here for a demo:

http://yihui.name/knitr/demo/minimal/

But I don't know how to get the LaTeX to render. If I just
push it and look at in the branch, here's what I get:

https://github.com/stan-dev/example-models/blob/issue-34-case-study-egs/knitr/efron-morris/pool-no-pool.md

No rendering. And it looks like GitHub doesn't want to
render MathJax due to security concerns (don't know what
those are).

Another option is to use pandoc directly to generate HTML.
I'm guessing that's what Rstudio is doing. And Rstudio is
getting the MathJax to work.

I looked up MathJax, and it's primarily client-side. They just
released 2.6 (as in today!):

https://www.mathjax.org/mathjax-v2-6-now-available/

which has server-side support. But unless we run our own servers,
I don't see how that's going to help.


Jupyter
-------

I should probably figure out how to use Jupyter. Could someone else
see what it produces for output? We don't want to host modifiable or
runnable Jupyter docs on mc-stan.org, just HTML (or .md that converts
to HTML) that we can read. Then we want to make the source available.


- Bob

Jeffrey Arnold

unread,
Dec 30, 2015, 4:57:02 PM12/30/15
to stan...@googlegroups.com
For the knitr, you'd have to compile to the markdown files to HTML and then host the pages on the gh-pages branch of the repository. Then the mathjax will do the work. If you use rmarkdown it will do most of that for you, and include the figures as Base64 encoded data.




- Bob

--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Carpenter

unread,
Dec 30, 2015, 6:21:51 PM12/30/15
to stan...@googlegroups.com
Thanks --- I just needed to install pandoc on my
system path and then when I restarted R I could
run

> render("foo.md")

and it produced one of those monster HTML files. Cool.

But it was 850KB, which is a bummer because it was just
150KB or so of pngs pre-conversion. And the math seems to
be being stored as MathJax, not images --- it's nice and crisp,
unlike the images (which are too small coming out of knitr).

- Bob

Allen B. Riddell

unread,
Dec 30, 2015, 6:37:57 PM12/30/15
to stan...@googlegroups.com
On 12/30, Jeffrey Arnold wrote:
> For the knitr, you'd have to compile to the markdown files to HTML and then
> host the pages on the gh-pages branch of the repository. Then the mathjax
> will do the work. If you use rmarkdown it will do most of that for you, and
> include the figures as Base64 encoded data.
>

You can setup travis or jenkins to do this (compile + push to the
gh-pages branch) automatically.

Ben Goodrich

unread,
Dec 30, 2015, 7:54:20 PM12/30/15
to stan development mailing list
On Wednesday, December 30, 2015 at 6:21:51 PM UTC-5, Bob Carpenter wrote:
Thanks --- I just needed to install pandoc on my
system path and then when I restarted R I could
run

> render("foo.md")

and it produced one of those monster HTML files.  Cool.

But it was 850KB, which is a bummer because it was just
150KB or so of pngs pre-conversion.  And the math seems to
be being stored as MathJax, not images --- it's nice and crisp,
unlike the images (which are too small coming out of knitr).

Specify

output: 
  html_document: 
    self_contained: no

in the header of the .Rmd file. Possibly also specify fig.path in the setup chunk.

Ben

Reply all
Reply to author
Forward
0 new messages