From 3651f678a719ae3a35825bcb4e0dabbc7c60d8df Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 26 Jan 2021 00:31:00 +0900 Subject: [ruby/rdoc] Support GFM table https://github.com/ruby/rdoc/commit/9dc933df16 --- lib/rdoc/markup/table.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/rdoc/markup/table.rb (limited to 'lib/rdoc/markup/table.rb') diff --git a/lib/rdoc/markup/table.rb b/lib/rdoc/markup/table.rb new file mode 100644 index 0000000000..7bcb10aff3 --- /dev/null +++ b/lib/rdoc/markup/table.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true +## +# A section of table + +class RDoc::Markup::Table + attr_accessor :header, :align, :body + + def initialize header, align, body + @header, @align, @body = header, align, body + end + + def == other + self.class == other.class and + @header == other.header and + @align == other.align and + @body == other.body + end + + def accept visitor + visitor.accept_table @header, @body, @align + end + + def pretty_print q # :nodoc: + q.group 2, '[Table: ', ']' do + q.group 2, '[Head: ', ']' do + q.seplist @header.zip(@align) do |text, align| + q.pp text + if align + q.text ":" + q.breakable + q.text align.to_s + end + end + end + q.breakable + q.group 2, '[Body: ', ']' do + q.seplist @body do |body| + q.group 2, '[', ']' do + q.seplist body do |text| + q.pp text + end + end + end + end + end + end +end -- cgit v1.2.3