summaryrefslogtreecommitdiff
path: root/lib/rdoc/markup/to_html.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2021-01-26 00:31:00 +0900
committerNobuyoshi Nakada <[email protected]>2021-03-16 15:47:27 +0900
commit3651f678a719ae3a35825bcb4e0dabbc7c60d8df (patch)
treef8705c06212e4778780c1db52b99ae17d319e33d /lib/rdoc/markup/to_html.rb
parent05898c5b9001c0b1e8bd7bf0d12b42a8e7c388b8 (diff)
[ruby/rdoc] Support GFM table
https://github.com/ruby/rdoc/commit/9dc933df16
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4274
Diffstat (limited to 'lib/rdoc/markup/to_html.rb')
-rw-r--r--lib/rdoc/markup/to_html.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb
index 3b1b0e9d40..e2a00bd8a1 100644
--- a/lib/rdoc/markup/to_html.rb
+++ b/lib/rdoc/markup/to_html.rb
@@ -314,6 +314,29 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
@res << raw.parts.join("\n")
end
+ ##
+ # Adds +table+ to the output
+
+ def accept_table header, body, aligns
+ @res << "\n<table role=\"table\">\n<thead>\n<tr>\n"
+ header.zip(aligns) do |text, align|
+ @res << '<th'
+ @res << ' align="' << align << '"' if align
+ @res << '>' << CGI.escapeHTML(text) << "</th>\n"
+ end
+ @res << "</tr>\n</thead>\n<tbody>\n"
+ body.each do |row|
+ @res << "<tr>\n"
+ row.zip(aligns) do |text, align|
+ @res << '<td'
+ @res << ' align="' << align << '"' if align
+ @res << '>' << CGI.escapeHTML(text) << "</td>\n"
+ end
+ @res << "</tr>\n"
+ end
+ @res << "</tbody>\n</table>\n"
+ end
+
# :section: Utilities
##