Coverage for gramex\transforms\rmarkdown.py : 33%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import tornado.gen
4@tornado.gen.coroutine
5def rmarkdown(content, handler=None, **kwargs):
6 '''
7 A transform that converts Rmarkdown files to HTML.
9 HTML file is placed at path: $YAMLPATH location.
10 '''
11 import gramex.ml
12 import gramex.cache
13 import gramex.services
15 rmdfilepath = str(handler.file)
16 htmlpath = yield gramex.services.info.threadpool.submit(
17 gramex.ml.r,
18 '''
19 library(rmarkdown)
20 rmarkdown::render("{}", output_format="html_document", quiet=TRUE)
21 '''.format(rmdfilepath.replace('\\', '/'))
22 )
23 raise tornado.gen.Return(
24 gramex.cache.open(htmlpath[0], 'bin').decode('utf-8'))