Skip to content

Use distinct styles for note lists and label lists #1209

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

Merged
merged 5 commits into from
Dec 8, 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
22 changes: 19 additions & 3 deletions lib/rdoc/generator/template/darkfish/css/rdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,30 @@ main dl {
}

main dt {
margin-bottom: 0.5em;
line-height: 1.5; /* matches `main p` */
font-weight: bold;
}

main dl.note-list dt {
margin-right: 1em;
float: left;
font-weight: bold;
}

main dl.note-list dt:has(+ dt) {
margin-right: 0.25em;
}

main dl.note-list dt:has(+ dt)::after {
content: ', ';
font-weight: normal;
}

main dd {
margin: 0 1em 1em 0.5em;
margin: 0 0 1em 1em;
}

main dd p:first-child {
margin-top: 0;
}

/* Headers within Main */
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/markup/to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def list_item_start(list_item, list_type)
"<li>"
when :LABEL, :NOTE then
Array(list_item.label).map do |label|
"<dt>#{to_html label}\n"
"<dt>#{to_html label}</dt>\n"
end.join << "<dd>"
else
raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
Expand Down
12 changes: 6 additions & 6 deletions test/rdoc/test_rdoc_markup_to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ def accept_list_item_start_bullet
end

def accept_list_item_start_label
assert_equal "<dl class=\"rdoc-list label-list\"><dt>cat\n<dd>", @to.res.join
assert_equal "<dl class=\"rdoc-list label-list\"><dt>cat</dt>\n<dd>", @to.res.join
end

def accept_list_item_start_lalpha
assert_equal "<ol style=\"list-style-type: lower-alpha\"><li>", @to.res.join
end

def accept_list_item_start_note
assert_equal "<dl class=\"rdoc-list note-list\"><dt>cat\n<dd>",
assert_equal "<dl class=\"rdoc-list note-list\"><dt>cat</dt>\n<dd>",
@to.res.join
end

def accept_list_item_start_note_2
expected = <<-EXPECTED
<dl class="rdoc-list note-list"><dt><code>teletype</code>
<dl class="rdoc-list note-list"><dt><code>teletype</code></dt>
<dd>
<p>teletype description</p>
</dd></dl>
Expand All @@ -171,7 +171,7 @@ def accept_list_item_start_note_2

def accept_list_item_start_note_multi_description
expected = <<-EXPECTED
<dl class="rdoc-list note-list"><dt>label
<dl class="rdoc-list note-list"><dt>label</dt>
<dd>
<p>description one</p>
</dd><dd>
Expand All @@ -184,8 +184,8 @@ def accept_list_item_start_note_multi_description

def accept_list_item_start_note_multi_label
expected = <<-EXPECTED
<dl class="rdoc-list note-list"><dt>one
<dt>two
<dl class="rdoc-list note-list"><dt>one</dt>
<dt>two</dt>
<dd>
<p>two headers</p>
</dd></dl>
Expand Down
Loading