File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Tag
99 'StrikeThrough' => Callbacks ::StrikeThrough
1010 } . freeze
1111
12- TAG_CLASSES = %w[ A B Blockquote Body Br Code Del Div H Hr I Img Li Mark Ol P Pre Small Span Sub Sup U Ul ] . freeze
12+ TAG_CLASSES = %w[ A B Blockquote Body Br Code Del Div H Hr I Img Li Mark Ol P Pre Small Span Sub Sup Table Td Tr U Ul ] . freeze
1313
1414 def_delegators :@attrs , :styles , :update_styles
1515
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module PrawnHtml
4+ module Tags
5+ class Table < Tag
6+ ELEMENTS = [ :table ] . freeze
7+
8+ attr_reader :table_data
9+
10+ def block?
11+ true
12+ end
13+
14+ def new_cell
15+ @col_index += 1
16+ @table_data [ @row_index ] << ''
17+ end
18+
19+ def new_row
20+ @row_index += 1
21+ @col_index = -1
22+ @table_data << [ ]
23+ end
24+
25+ def update_content ( content )
26+ @table_data [ @row_index ] [ @col_index ] = content
27+ end
28+
29+ def tag_opening ( context : nil )
30+ super . tap do
31+ context . current_table = self
32+ @row_index = -1
33+ @table_data = [ ]
34+ end
35+ end
36+ end
37+ end
38+ end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module PrawnHtml
4+ module Tags
5+ class Td < Tag
6+ ELEMENTS = [ :td ] . freeze
7+
8+ def block?
9+ true
10+ end
11+
12+ def tag_opening ( context : nil )
13+ super . tap do
14+ context . current_table &.new_cell
15+ end
16+ end
17+ end
18+ end
19+ end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module PrawnHtml
4+ module Tags
5+ class Tr < Tag
6+ ELEMENTS = [ :tr ] . freeze
7+
8+ def block?
9+ true
10+ end
11+
12+ def tag_opening ( context : nil )
13+ super . tap do
14+ context . current_table &.new_row
15+ end
16+ end
17+ end
18+ end
19+ end
You can’t perform that action at this time.
0 commit comments