Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mdman] Normalize newlines when rendering options #14428

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/mdman/src/hbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ impl HelperDef for OptionHelper<'_> {
// Render the block.
let block = t.renders(r, gctx, rc)?;

// Windows newlines can break some rendering, so normalize.
let block = block.replace("\r\n", "\n");
epage marked this conversation as resolved.
Show resolved Hide resolved

// Get the name of this page.
let man_name = gctx
.data()
Expand Down
5 changes: 5 additions & 0 deletions crates/mdman/tests/compare/expected/options.1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ Flag with optional value.
.RS 4
Alternate syntax for optional value (with required = for disambiguation).
.RE
.sp
\fB\-\-split\-block\fR
.RS 4
An option where the description has a \fBblock statement that is split across multiple lines\fR
.RE
.SH "EXAMPLES"
.sp
.RS 4
Expand Down
4 changes: 4 additions & 0 deletions crates/mdman/tests/compare/expected/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ A description of the command.
<dd class="option-desc">Alternate syntax for optional value (with required = for disambiguation).</dd>


<dt class="option-term" id="option-options---split-block"><a class="option-anchor" href="#option-options---split-block"></a><code>--split-block</code></dt>
<dd class="option-desc">An option where the description has a <code>block statement that is split across multiple lines</code></dd>


</dl>


Expand Down
4 changes: 4 additions & 0 deletions crates/mdman/tests/compare/expected/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ OPTIONS
Alternate syntax for optional value (with required = for
disambiguation).

--split-block
An option where the description has a block statement that is split
across multiple lines

EXAMPLES
1. An example

Expand Down
5 changes: 5 additions & 0 deletions crates/mdman/tests/compare/includes/options-common.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ Flag with optional value.
Alternate syntax for optional value (with required = for disambiguation).
{{/option}}

{{#option "`--split-block`"}}
An option where the description has a `block statement
that is split across multiple lines`
{{/option}}

{{/options}}