WrapRmd icon indicating copy to clipboard operation
WrapRmd copied to clipboard

Ignore code blocks and yaml

Open cpsievert opened this issue 8 years ago • 3 comments

It seems that code blocks and yaml are being wrapped, for instance:

```{r}
layout(
   subplot(p2),
   yaxis2 = list(title = ""), 
  yaxis3 = list(title = "")
)
```

becomes

```{r} layout( subplot(p2), yaxis2 = list(title = ""), yaxis3 = list(title =
"") ) ```

Would it be possible to ignore code chunks and yaml?

cpsievert avatar Apr 14 '16 05:04 cpsievert

That might be difficult to do correctly and comprehensively, like requiring a detailed parsing of the selected text. I could try some heuristics, such as not wrapping anything within a fenced code block.

tjmahr avatar Apr 14 '16 14:04 tjmahr

I would appreciate this as well. My use case here is formatting an entire inherited .Rmd with chaotic line breaks via Ctrl + A >> Ctrl + Shift + Alt + /, but this currently breaks YAML headers.

alexpghayes avatar Sep 06 '22 15:09 alexpghayes

Setting this help wanted. For whole document transformation, we probably need to send the text to pandoc for parsing, traverse the tree to escape to `r code` bits, get the wrapped output and unescape it.

As a fix: Does switching to the visual editor, have it use column-based line-wrapping, and switching back to text editor solve it?

tjmahr avatar Sep 09 '22 16:09 tjmahr