Recall that knitr allows you to set custom output hooks to address this,
e.g.
hook.t <- function(x, options) paste0("\n\n~~~\n", paste0(x,
collapse="\n"), "~~~\n\n")
hook.r <- function(x, options) {
paste0("\n\n~~~ ", tolower(options$engine), "\n", paste0(x,
collapse="\n"), "\n~~~\n\n")
}
knitr::knit_hooks$set(source=hook.r, output=hook.t, warning=hook.t,
error=hook.t, message=hook.t)
should do it.
On Fri Dec 05 2014 at 6:07:11 AM François Michonneau <
[email protected]> wrote:
>
> For R that might be an issue. As far as I know, using ~~~ doesn't work
> with knitr, as it only recongizes ``` as the delimiter of code that needs
> to be evaluated.
>
> Cheers,
> -- François
>
> /tmp $ cat test.Rmd
>
> A simple test
>
> ~~~{r}
> rnorm(10)
> ~~~
>
> ```{r}
> rnorm(10)
> ```
>
> /tmp $ Rscript -e "knitr::knit('test.Rmd')"
>
>
> processing file: test.Rmd
> |................................ | 50%
> ordinary text without R code
>
> |.................................................................| 100%
> label: unnamed-chunk-1
>
> output file: test.md
>
> [1] "test.md"
> /tmp $ cat test.md
>
> A simple test
>
> ~~~{r}
> rnorm(10)
> ~~~
>
>
> ```r
> rnorm(10)
> ```
>
> ```
> ## [1] 0.39359233 2.48256464 -2.73909990 -1.05240780 -0.02435052
> ## [6] -0.34673051 0.47497016 -0.08881003 -1.44839210 -0.83156610
> ```
>
> On Fri, Dec 5, 2014 at 7:31 AM, Greg Wilson <
> [email protected]> wrote:
>
>> Thanks Raniere - can you please open an issue against the validator [1]
>> to check this? There are many variations on Markdown out there that people
>> might be used to, so we should check that authors are using the one we want
>> in our lessons.
>>
>> Thanks,
>> Greg
>>
>> p.s. and as a follow-up to yesterday's lab meeting, anyone who has some
>> time to do a bit of Python coding to help us get that validator finished
>> would be very welcome to dive in...
>>
>> [1] https://github.com/swcarpentry/lesson-template
>>
>>
>> On 2014-12-05 7:17 AM, Raniere Silva wrote:
>>
>> Hi,
>>
>> when reviewing the lessons for a workshop next week I notice some problems
>> with code samples. What I found out is
>>
>> $ cat quote.md
>> ```
>> foobar
>> ```
>> $ kramdown quote.md
>> <p><code>
>> foobar
>> </code></p>
>> $ cat tilde.md
>> ~~
>> foobar
>> ~~
>> $ kramdown tilde.md
>> <pre><code>foobar
>> </code></pre>
>>
>> When you use ``` as code block delimiter kramdown
>> (the parser used by Jekyll/GitHub Pages) doesn't
>> insert the <pre> tag and because of it all the code sample
>> is display in the same line (at least with Firefox).
>>
>> Please use ~~~ as code block delimiter when using Jekyll/GitHub Pages.
>>
>> I report this bug at https://github.com/gettalong/kramdown/issues/189.
>>
>> Cheers,
>> Raniere
>>
>>
>>
>> _______________________________________________
>> Discuss mailing
>> [email protected]http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org
>>
>>
>> --
>> Dr. Greg Wilson | [email protected]
>> Software Carpentry | http://software-carpentry.org
>>
>>
>> _______________________________________________
>> Discuss mailing list
>> [email protected]
>>
>> http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org
>>
>
> _______________________________________________
> Discuss mailing list
> [email protected]
> http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.
> software-carpentry.org
_______________________________________________
Discuss mailing list
[email protected]
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org