File tree Expand file tree Collapse file tree 4 files changed +83
-1
lines changed Expand file tree Collapse file tree 4 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Tag
9
9
'StrikeThrough' => Callbacks ::StrikeThrough
10
10
} . freeze
11
11
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
13
13
14
14
def_delegators :@attrs , :styles , :update_styles
15
15
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_accessor :rows
9
+
10
+ def block?
11
+ true
12
+ end
13
+
14
+ def new_cell
15
+ @col_index += 1
16
+ @rows [ @row_index ] << ''
17
+ end
18
+
19
+ def new_row
20
+ @row_index += 1
21
+ @col_index = -1
22
+ @rows << [ ]
23
+ end
24
+
25
+ def update_content ( content )
26
+ @rows [ @row_index ] [ @col_index ] = content
27
+ end
28
+
29
+ def tag_opening ( pdf : nil , context : nil )
30
+ super . tap do
31
+ context . current_table = self
32
+ @row_index = -1
33
+ @rows = [ ]
34
+ end
35
+ end
36
+
37
+ def tag_closing ( pdf : nil , context : nil )
38
+ super . tap do
39
+ pdf . table ( @rows )
40
+ end
41
+ end
42
+ end
43
+ end
44
+ 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 ( pdf : nil , 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 ( pdf : nil , 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