Strip leading trailing empty lines in doc code blocks#103376
Strip leading trailing empty lines in doc code blocks#103376GuillaumeGomez wants to merge 2 commits intorust-lang:mainfrom
Conversation
|
r? @notriddle (rust-highfive has picked a reviewer for you, use r? to override) |
|
|
||
| <span class="comment">// bye</span></code></pre></div> | ||
| "#, | ||
| ); |
There was a problem hiding this comment.
Please add a test case with boring lines at the start and end, since these are the use cases that actually motivate this feature.
t(
"\
```
# hello
f();
# goodbye
```",
r#"
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>f();</code></pre></div>
"#,
);|
On a broader note, I don't really like this approach, since the CommonMark spec specifically says that empty lines in fenced code blocks are supposed to be preserved, even if the entire code block is nothing but newlines. But it probably doesn't matter in practice. |
|
Hence why I'm asking everyone's opinion on this. This is the simplest approach but we can also only remove commented lines and keep all the others or have a mix and remove lines if it starts or ends with commented lines. |
|
☔ The latest upstream changes (presumably #105554) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixes #102996.
We currently have an inconsistent way of handling leading and trailing empty lines in doc code blocks (some examples in the linked issue). With this PR, I propose to remove all of them, whether there is hidden code or not. So for example:
will be rendered like this:
What do you think @rust-lang/rustdoc ?