Skip to content
Closed
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
6 changes: 5 additions & 1 deletion lib/rdoc/markup/to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,11 @@ def accept_heading heading
label = [@code_object.aref, label].compact.join '-' if
@code_object and @code_object.respond_to? :aref

@res << "\n<h#{level} id=\"#{label}\">"
@res << if @options.output_decoration
"\n<h#{level} id=\"#{label}\">"
else
"\n<h#{level}>"
end
@res << to_html(heading.text)
unless @options.pipe then
@res << "<span><a href=\"##{label}\">&para;</a>"
Expand Down
5 changes: 5 additions & 0 deletions lib/rdoc/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ class RDoc::Options

attr_accessor :option_parser

##
# Output heading decorations?
attr_accessor :output_decoration

##
# Directory where guides, FAQ, and other pages not associated with a class
# live. You may leave this unset if these are at the root of your project.
Expand Down Expand Up @@ -337,6 +341,7 @@ def init_ivars # :nodoc:
@op_dir = nil
@page_dir = nil
@pipe = false
@output_decoration = true
@rdoc_include = []
@root = Pathname(Dir.pwd)
@show_hash = false
Expand Down
21 changes: 21 additions & 0 deletions test/test_rdoc_markup_to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,27 @@ def test_accept_heading_pipe
assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
end

def test_accept_heading_output_decoration
@options.output_decoration = false

@to.start_accepting

@to.accept_heading @RM::Heading.new(1, 'Hello')

assert_equal "\n<h1>Hello<span><a href=\"#label-Hello\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>\n", @to.res.join
end

def test_accept_heading_output_decoration_with_pipe
@options.pipe = true
@options.output_decoration = false

@to.start_accepting

@to.accept_heading @RM::Heading.new(1, 'Hello')

assert_equal "\n<h1>Hello</h1>\n", @to.res.join
end

def test_accept_verbatim_parseable
verb = @RM::Verbatim.new("class C\n", "end\n")

Expand Down