可以从knitr生成MediaWiki标记吗?

时间:2022-09-25 23:30:12

I am producing a report which will be published in pdf format. It concerns statistics and particularly the use of R. Therefore I am using knitr. I would also like to publish it to a wiki, with minimal extra effort by me!

我正在制作一份报告,将以pdf格式出版。它涉及统计数据,特别是r的使用,因此我使用knitr。我也想把它发布到一个*上,我付出了最小的努力!

Is it possible to get wiki markup (MediaWiki) output from knitr?

是否可能从knitr获得wiki标记(MediaWiki)输出?

Or, if I generate HTML from knitr, can HTML be given directly to the wiki?

或者,如果我从knitr生成HTML, HTML可以直接给wiki吗?

This problem is related to this post. Wiki markup rules are here, but I can't quite see if full HTML is supported.

这个问题与这篇文章有关。这里有Wiki标记规则,但我不太清楚是否支持完整的HTML。

Thanks.

谢谢。

1 个解决方案

#1


4  

You can certainly define the markup rules in knitr output hooks: http://yihui.name/knitr/hooks As one simple example, you can highlight source code with <syntaxhighlight>:

您当然可以在knitr输出挂钩中定义标记规则:http://yihui.name/knitr/hooks作为一个简单的示例,您可以使用 突出显示源代码:

knit_hooks$set(source = function(x, options) {
  sprintf('<syntaxhighlight lang=%s>%s</syntaxhighlight>', options$engine, x)
})

You are free to design the rest of the output hooks. But as Ben Bolker pointed out, I think you are better off with Markdown, and convert that to Mediawiki via Pandoc.

您可以*地设计其余的输出挂钩。但是正如Ben Bolker指出的,我认为你最好使用Markdown,然后通过Pandoc将其转换为Mediawiki。

#1


4  

You can certainly define the markup rules in knitr output hooks: http://yihui.name/knitr/hooks As one simple example, you can highlight source code with <syntaxhighlight>:

您当然可以在knitr输出挂钩中定义标记规则:http://yihui.name/knitr/hooks作为一个简单的示例,您可以使用 突出显示源代码:

knit_hooks$set(source = function(x, options) {
  sprintf('<syntaxhighlight lang=%s>%s</syntaxhighlight>', options$engine, x)
})

You are free to design the rest of the output hooks. But as Ben Bolker pointed out, I think you are better off with Markdown, and convert that to Mediawiki via Pandoc.

您可以*地设计其余的输出挂钩。但是正如Ben Bolker指出的,我认为你最好使用Markdown,然后通过Pandoc将其转换为Mediawiki。