[ruby/rdoc] Support GFM table

9dc933df16
This commit is contained in:
Nobuyoshi Nakada 2021-01-26 00:31:00 +09:00
parent 05898c5b90
commit 3651f678a7
Notes: git 2021-03-16 15:47:54 +09:00
8 changed files with 471 additions and 2 deletions

View file

@ -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
##