Open DanStevens opened 6 years ago
Hi,
That content within a code block (fenced (```), or indented) is by design. For the same reason that code within source files isn't rewrapped: code is something you normally don't want messed with.
However, I could add a feature that comments within code blocks in markdown files are wrapped. I'm guessing you have something like this?
Hendrerit adolescens vim ad, qualisque delicatissimi ad sit.
``` js
// Eos et tractatos intellegam, usu omnium sapientem disputationi ea.
function fib(n) {
return n < 2 ? 1 : (fib(n - 2) + fib(n - 1))
}
```
Here the comment in the code could also be wrapped, as long as you have a language marker after the ```
(in this case js
). (This means it won't work with indented code blocks as they have no language marker)
Hendrerit adolescens vim ad, qualisque
delicatissimi ad sit.
``` js
// Eos et tractatos intellegam, usu
// omnium sapientem disputationi ea.
function fib(n) {
return n < 2 ? 1 : (fib(n - 2) + fib(n - 1))
}
```
Note the text above and comment within the code are wrapped, but not the code itself.
Plain text files (.txt
) don't use the markdown parser which is why they don't recognise code blocks and you don't see the same behaviour.
I see - it makes sense that you may not want rewrap to wrap source code. In my particular case I was wanting to wrap YAML code within a markdown code block, which contained long strings that I wanted to wrap.
If rewrap were to wrap comments within a markdown code block, and a user really did want to wrap source code, they could convert the code to a comment, wrap, then uncomment.
I'm using rewwap to write documentation, which has a lot of codeblocks in markdown with comments. I would also like rewrap to be able to wrap the comments in the codeblocks!
The
Rewrap Comment / Text
command doesn't appear to work within a code block for markdown files.For example, suppose the
rewrap.reformat
setting has a value of30
and I have a file namedtest.md
as follows:After running the
Rewrap Comment / Text
command, the result is:The first paragraph has been rewrapped, but the second hasn't. The same happens if instead I indent the second paragraphs instead of using triple backticks:
This doesn't affect plain text files - if I create a file named
test.txt
with the same content astest.md
, the result of the wrap is:Is this by designed? If so, can I setting be created to allow control over this behaviour?