Skip to content

Commit 0540bde

Browse files
authored
Fix links for options in man pages (#16172)
This fixes a mistake where the `<a>` tag was closed in the wrong spot causing the links to not be functional. It was intended that you can click on the option in order to get a link reference to the option, just like you can do with headers.
2 parents 6c1b610 + 7f673e8 commit 0540bde

40 files changed

+976
-973
lines changed

crates/mdman/doc/out/mdman.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ man page:
5353

5454
<dl>
5555

56-
<dt class="option-term" id="option-mdman--t"><a class="option-anchor" href="#option-mdman--t"></a><code>-t</code> <em>type</em></dt>
56+
<dt class="option-term" id="option-mdman--t"><a class="option-anchor" href="#option-mdman--t"><code>-t</code> <em>type</em></a></dt>
5757
<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
@@ -66,26 +66,26 @@ available. Outputs with the <code>.txt</code> extension.</li>
6666
</dd>
6767

6868

69-
<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+
<dt class="option-term" id="option-mdman--o"><a class="option-anchor" href="#option-mdman--o"><code>-o</code> <em>outdir</em></a></dt>
7070
<dd class="option-desc"><p>Specifies the directory where to save the output.</p>
7171
</dd>
7272

7373

74-
<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>
74+
<dt class="option-term" id="option-mdman---url"><a class="option-anchor" href="#option-mdman---url"><code>--url</code> <em>base_url</em></a></dt>
7575
<dd class="option-desc"><p>Specifies a base URL to use for relative URLs within the document. Any
7676
relative URL will be joined with this URL.</p>
7777
</dd>
7878

7979

80-
<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>
80+
<dt class="option-term" id="option-mdman---man"><a class="option-anchor" href="#option-mdman---man"><code>--man</code> <em>name</em><code>:</code><em>section</em><code>=</code><em>url</em></a></dt>
8181
<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
8282
may be specified multiple times. If a man page reference does not have a
8383
matching <code>--man</code> entry, then a relative link to a file named <em>name</em><code>.md</code> will
8484
be used.</p>
8585
</dd>
8686

8787

88-
<dt class="option-term" id="option-mdman-sources…"><a class="option-anchor" href="#option-mdman-sources…"></a><em>sources…</em></dt>
88+
<dt class="option-term" id="option-mdman-sources…"><a class="option-anchor" href="#option-mdman-sources…"><em>sources…</em></a></dt>
8989
<dd class="option-desc"><p>The source input filename, may be specified multiple times.</p>
9090
</dd>
9191

crates/mdman/src/format/md.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ impl super::Formatter for MdFormatter {
5858
let id = format!("option-{}-{}", man_name, no_tags);
5959
write!(
6060
result,
61-
"<dt class=\"option-term\" id=\"{ID}\">\
62-
<a class=\"option-anchor\" href=\"#{ID}\"></a>{OPTION}</dt>\n",
63-
ID = id,
64-
OPTION = no_p
61+
"<dt class=\"option-term\" id=\"{id}\">\
62+
<a class=\"option-anchor\" href=\"#{id}\">{no_p}</a></dt>\n",
6563
)?;
6664
}
6765
let rendered_block = self.render_html(block)?;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Shortcut unknown: [shortcut unknown]
3333
[Some link](foo.html)
3434

3535
<dl>
36-
<dt class="option-term" id="option-links---include"><a class="option-anchor" href="#option-links---include"></a><code>--include</code></dt>
36+
<dt class="option-term" id="option-links---include"><a class="option-anchor" href="#option-links---include"><code>--include</code></a></dt>
3737
<dd class="option-desc"><p>Testing an <a href="included_link.html">included link</a>.</p>
3838
</dd>
3939

@@ -44,7 +44,7 @@ Shortcut unknown: [shortcut unknown]
4444

4545
<dl>
4646

47-
<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+
<dt class="option-term" id="option-links---foo-bar"><a class="option-anchor" href="#option-links---foo-bar"><code>--foo-bar</code></a></dt>
4848
<dd class="option-desc"><p>Example <a href="bar.html">link</a>.
4949
See <a href="https://example.org/commands/other-cmd.html">other-cmd(1)</a>, <a href="local-cmd.html">local-cmd(1)</a></p>
5050
</dd>

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ A description of the command.
2828

2929
<dl>
3030

31-
<dt class="option-term" id="option-options---foo-bar"><a class="option-anchor" href="#option-options---foo-bar"></a><code>--foo-bar</code></dt>
31+
<dt class="option-term" id="option-options---foo-bar"><a class="option-anchor" href="#option-options---foo-bar"><code>--foo-bar</code></a></dt>
3232
<dd class="option-desc"><p>Demo <em>emphasis</em>, <strong>strong</strong>, <del>strike</del></p>
3333
</dd>
3434

3535

36-
<dt class="option-term" id="option-options--p"><a class="option-anchor" href="#option-options--p"></a><code>-p</code> <em>spec</em></dt>
37-
<dt class="option-term" id="option-options---package"><a class="option-anchor" href="#option-options---package"></a><code>--package</code> <em>spec</em></dt>
36+
<dt class="option-term" id="option-options--p"><a class="option-anchor" href="#option-options--p"><code>-p</code> <em>spec</em></a></dt>
37+
<dt class="option-term" id="option-options---package"><a class="option-anchor" href="#option-options---package"><code>--package</code> <em>spec</em></a></dt>
3838
<dd class="option-desc"><p>This has multiple flags.</p>
3939
</dd>
4040

4141

42-
<dt class="option-term" id="option-options-named-arg…"><a class="option-anchor" href="#option-options-named-arg…"></a><em>named-arg…</em></dt>
42+
<dt class="option-term" id="option-options-named-arg…"><a class="option-anchor" href="#option-options-named-arg…"><em>named-arg…</em></a></dt>
4343
<dd class="option-desc"><p>A named argument.</p>
4444
</dd>
4545

4646

47-
<dt class="option-term" id="option-options---complex"><a class="option-anchor" href="#option-options---complex"></a><code>--complex</code></dt>
47+
<dt class="option-term" id="option-options---complex"><a class="option-anchor" href="#option-options---complex"><code>--complex</code></a></dt>
4848
<dd class="option-desc"><p>This option has a list.</p>
4949
<ul>
5050
<li>alpha</li>
@@ -60,22 +60,22 @@ A description of the command.
6060
### Common Options
6161

6262
<dl>
63-
<dt class="option-term" id="option-options-@filename"><a class="option-anchor" href="#option-options-@filename"></a><code>@</code><em>filename</em></dt>
63+
<dt class="option-term" id="option-options-@filename"><a class="option-anchor" href="#option-options-@filename"><code>@</code><em>filename</em></a></dt>
6464
<dd class="option-desc"><p>Load from filename.</p>
6565
</dd>
6666

6767

68-
<dt class="option-term" id="option-options---foo"><a class="option-anchor" href="#option-options---foo"></a><code>--foo</code> [<em>bar</em>]</dt>
68+
<dt class="option-term" id="option-options---foo"><a class="option-anchor" href="#option-options---foo"><code>--foo</code> [<em>bar</em>]</a></dt>
6969
<dd class="option-desc"><p>Flag with optional value.</p>
7070
</dd>
7171

7272

73-
<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>
73+
<dt class="option-term" id="option-options---foo[=bar]"><a class="option-anchor" href="#option-options---foo[=bar]"><code>--foo</code>[<code>=</code><em>bar</em>]</a></dt>
7474
<dd class="option-desc"><p>Alternate syntax for optional value (with required = for disambiguation).</p>
7575
</dd>
7676

7777

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

0 commit comments

Comments
 (0)