Skip to content

Commit

Permalink
Merge pull request #277 from mojavelinux/issue-272
Browse files Browse the repository at this point in the history
resolves #272 allow theme to control header cells in table body
  • Loading branch information
mojavelinux committed Jul 25, 2015
2 parents 89f6a8e + d28be7f commit 034881e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
28 changes: 28 additions & 0 deletions docs/theming-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,10 @@ Block styles are applied to the following block types:
|<<colors,color>>
|background_color: #ffffff

|table_head_background_color
|<<colors,color>>
|background_color: #f0f0f0

|table_even_row_background_color
|<<colors,color>>
|even_row_background_color: #f9f9f9
Expand All @@ -1314,6 +1318,30 @@ Block styles are applied to the following block types:
|<<colors,color>>
|foot_background_color: #f0f0f0

|table_header_cell_align
|left, center, right
|align: center

|table_header_cell_background_color
|<<colors,color>>
|background_color: #f0f0f0

|table_header_cell_font_color
|<<colors,color>>
|font_color: #1a1a1a

|table_header_cell_font_family
|<<fonts,font family name>>
|font_family: Noto Sans

|table_header_cell_font_size
|<<values,number>>
|font_size: 12

|table_header_cell_font_style
|normal, italic, bold, bold_italic
|font_style: italic

|table_border_color
|<<colors,color>>
|border_color: #dddddd
Expand Down
23 changes: 22 additions & 1 deletion lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,29 @@ def convert_table node
case cell.style
when :emphasis
cell_data[:font_style] = :italic
when :strong, :header
when :strong
cell_data[:font_style] = :bold
when :header
unless defined? header_cell_data
header_cell_data = {}
{
'align' => :align,
'font_color' => :text_color,
'font_family' => :font,
'font_size' => :size,
'font_style' => :font_style
}.each do |theme_key, key|
if (val = theme[%(table_header_cell_#{theme_key})])
header_cell_data[key] = val
end
end
header_cell_data[:font_style] ||= :bold
if (val = resolve_theme_color :table_header_cell_background_color)
header_cell_data[:background_color] = val
end
end

cell_data.update header_cell_data unless header_cell_data.empty?
when :monospaced
cell_data[:font] = theme.literal_font_family
if (size = theme.literal_font_size)
Expand Down

0 comments on commit 034881e

Please sign in to comment.