Skip to content

Commit f9032ff

Browse files
committed
Fix mdman to not incorrectly strip <p> tags
The logic for stripping the `<p>` tag in the option description was not considering that the description may contain other block elements. This changes it so that it no longer strips the `<p>` tag. This was done due to some spacing issues which are better resolved with CSS (and is resolved in mdbook 0.5).
1 parent 192f1ef commit f9032ff

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

crates/mdman/doc/out/mdman.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,40 @@ man page:
5454
<dl>
5555

5656
<dt class="option-term" id="option-mdman--t"><a class="option-anchor" href="#option-mdman--t"></a><code>-t</code> <em>type</em></dt>
57-
<dd class="option-desc">Specifies the output type. The following output types are supported:</p>
57+
<dd class="option-desc"><p>Specifies the output type. The following output types are supported:</p>
5858
<ul>
5959
<li><code>man</code> — A troff-style man page. Outputs with a numbered extension (like
6060
<code>.1</code>) matching the man page section.</li>
6161
<li><code>md</code> — A markdown file, after all handlebars processing has been finished.
6262
Outputs with the <code>.md</code> extension.</li>
6363
<li><code>txt</code> — A text file, rendered for situations where a man page viewer isn’t
6464
available. Outputs with the <code>.txt</code> extension.</li>
65-
</ul></dd>
65+
</ul>
66+
</dd>
6667

6768

6869
<dt class="option-term" id="option-mdman--o"><a class="option-anchor" href="#option-mdman--o"></a><code>-o</code> <em>outdir</em></dt>
69-
<dd class="option-desc">Specifies the directory where to save the output.</dd>
70+
<dd class="option-desc"><p>Specifies the directory where to save the output.</p>
71+
</dd>
7072

7173

7274
<dt class="option-term" id="option-mdman---url"><a class="option-anchor" href="#option-mdman---url"></a><code>--url</code> <em>base_url</em></dt>
73-
<dd class="option-desc">Specifies a base URL to use for relative URLs within the document. Any
74-
relative URL will be joined with this URL.</dd>
75+
<dd class="option-desc"><p>Specifies a base URL to use for relative URLs within the document. Any
76+
relative URL will be joined with this URL.</p>
77+
</dd>
7578

7679

7780
<dt class="option-term" id="option-mdman---man"><a class="option-anchor" href="#option-mdman---man"></a><code>--man</code> <em>name</em><code>:</code><em>section</em><code>=</code><em>url</em></dt>
78-
<dd class="option-desc">Specifies a URL to use for the given man page. When the <code>{{man name section}}</code> expression is used, the given URL will be inserted as a link. This
81+
<dd class="option-desc"><p>Specifies a URL to use for the given man page. When the <code>{{man name section}}</code> expression is used, the given URL will be inserted as a link. This
7982
may be specified multiple times. If a man page reference does not have a
8083
matching <code>--man</code> entry, then a relative link to a file named <em>name</em><code>.md</code> will
81-
be used.</dd>
84+
be used.</p>
85+
</dd>
8286

8387

8488
<dt class="option-term" id="option-mdman-sources…"><a class="option-anchor" href="#option-mdman-sources…"></a><em>sources…</em></dt>
85-
<dd class="option-desc">The source input filename, may be specified multiple times.</dd>
89+
<dd class="option-desc"><p>The source input filename, may be specified multiple times.</p>
90+
</dd>
8691

8792

8893
</dl>

crates/mdman/src/format/md.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ impl super::Formatter for MdFormatter {
6767
let rendered_block = self.render_html(block)?;
6868
write!(
6969
result,
70-
"<dd class=\"option-desc\">{}</dd>\n\n",
71-
unwrap_p(&rendered_block)
70+
"<dd class=\"option-desc\">{rendered_block}</dd>\n\n",
7271
)?;
7372
Ok(result)
7473
}

crates/mdman/tests/compare/expected/links.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Shortcut unknown: [shortcut unknown]
3434

3535
<dl>
3636
<dt class="option-term" id="option-links---include"><a class="option-anchor" href="#option-links---include"></a><code>--include</code></dt>
37-
<dd class="option-desc">Testing an <a href="included_link.html">included link</a>.</dd>
37+
<dd class="option-desc"><p>Testing an <a href="included_link.html">included link</a>.</p>
38+
</dd>
3839

3940
</dl>
4041

@@ -44,8 +45,9 @@ Shortcut unknown: [shortcut unknown]
4445
<dl>
4546

4647
<dt class="option-term" id="option-links---foo-bar"><a class="option-anchor" href="#option-links---foo-bar"></a><code>--foo-bar</code></dt>
47-
<dd class="option-desc">Example <a href="bar.html">link</a>.
48-
See <a href="https://example.org/commands/other-cmd.html">other-cmd(1)</a>, <a href="local-cmd.html">local-cmd(1)</a></dd>
48+
<dd class="option-desc"><p>Example <a href="bar.html">link</a>.
49+
See <a href="https://example.org/commands/other-cmd.html">other-cmd(1)</a>, <a href="local-cmd.html">local-cmd(1)</a></p>
50+
</dd>
4951

5052

5153
</dl>

crates/mdman/tests/compare/expected/options.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,30 @@ A description of the command.
2929
<dl>
3030

3131
<dt class="option-term" id="option-options---foo-bar"><a class="option-anchor" href="#option-options---foo-bar"></a><code>--foo-bar</code></dt>
32-
<dd class="option-desc">Demo <em>emphasis</em>, <strong>strong</strong>, <del>strike</del></dd>
32+
<dd class="option-desc"><p>Demo <em>emphasis</em>, <strong>strong</strong>, <del>strike</del></p>
33+
</dd>
3334

3435

3536
<dt class="option-term" id="option-options--p"><a class="option-anchor" href="#option-options--p"></a><code>-p</code> <em>spec</em></dt>
3637
<dt class="option-term" id="option-options---package"><a class="option-anchor" href="#option-options---package"></a><code>--package</code> <em>spec</em></dt>
37-
<dd class="option-desc">This has multiple flags.</dd>
38+
<dd class="option-desc"><p>This has multiple flags.</p>
39+
</dd>
3840

3941

4042
<dt class="option-term" id="option-options-named-arg…"><a class="option-anchor" href="#option-options-named-arg…"></a><em>named-arg…</em></dt>
41-
<dd class="option-desc">A named argument.</dd>
43+
<dd class="option-desc"><p>A named argument.</p>
44+
</dd>
4245

4346

4447
<dt class="option-term" id="option-options---complex"><a class="option-anchor" href="#option-options---complex"></a><code>--complex</code></dt>
45-
<dd class="option-desc">This option has a list.</p>
48+
<dd class="option-desc"><p>This option has a list.</p>
4649
<ul>
4750
<li>alpha</li>
4851
<li>beta</li>
4952
<li>gamma</li>
5053
</ul>
51-
<p>Then text continues here.</dd>
54+
<p>Then text continues here.</p>
55+
</dd>
5256

5357

5458
</dl>
@@ -57,19 +61,23 @@ A description of the command.
5761

5862
<dl>
5963
<dt class="option-term" id="option-options-@filename"><a class="option-anchor" href="#option-options-@filename"></a><code>@</code><em>filename</em></dt>
60-
<dd class="option-desc">Load from filename.</dd>
64+
<dd class="option-desc"><p>Load from filename.</p>
65+
</dd>
6166

6267

6368
<dt class="option-term" id="option-options---foo"><a class="option-anchor" href="#option-options---foo"></a><code>--foo</code> [<em>bar</em>]</dt>
64-
<dd class="option-desc">Flag with optional value.</dd>
69+
<dd class="option-desc"><p>Flag with optional value.</p>
70+
</dd>
6571

6672

6773
<dt class="option-term" id="option-options---foo[=bar]"><a class="option-anchor" href="#option-options---foo[=bar]"></a><code>--foo</code>[<code>=</code><em>bar</em>]</dt>
68-
<dd class="option-desc">Alternate syntax for optional value (with required = for disambiguation).</dd>
74+
<dd class="option-desc"><p>Alternate syntax for optional value (with required = for disambiguation).</p>
75+
</dd>
6976

7077

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

7482

7583
</dl>

0 commit comments

Comments
 (0)