I think the output format html_fragment() will do what you need.
For example, if you have a file named fragment.Rmd that contains the following:
### Example
```{r}
a <- 1 + 1
a
```
You can render it to an HTML fragment with:
library(rmarkdown)
render("fragment.Rmd", html_fragment())
And the result is fragment.html which contains the following:
<div id="example" class="section level3">
<h3>Example</h3>
<pre class="r"><code>a <- 1 + 1
a</code></pre>
<pre><code>## [1] 2</code></pre>
</div>
Update: I realized that in your example you didn't evaluate the code chunk. To do this, you can specify the chunk option eval=FALSE. Then the output is closer to what you wanted:
<div id="example" class="section level3">
<h3>Example</h3>
<pre class="r"><code>a <- 1 + 1
a</code></pre>
</div>