Skip to content

Commit

Permalink
Merge pull request asciidoctor#197 from mojavelinux/issue-196
Browse files Browse the repository at this point in the history
resolves asciidoctor#196 add support for border style
  • Loading branch information
mojavelinux committed Jun 16, 2015
2 parents 7e9662f + fea1227 commit f29b626
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 43 deletions.
92 changes: 56 additions & 36 deletions docs/theming-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -661,14 +661,15 @@ TBW

|page_background_color
|<<colors,color>>
|background_color: ffffff
|background_color: #ffffff

|page_background_image
|path (relative to pdf-stylesdir)
|background_image: watermark.jpg

|page_layout
|portrait, landscape
|portrait, landscape +
(default: portrait)
|layout: portrait

|page_margin
Expand Down Expand Up @@ -732,7 +733,7 @@ TBW

|base_border_color
|<<colors,color>>
|border_color: eee
|border_color: #eeeeee
|===

^[1]^ You should set either `line_height` or `line_height_length` and derive the value of the other using a calculation since these are correlated values.
Expand Down Expand Up @@ -764,7 +765,7 @@ These keys predated the CSS-style theme system and are planned to be phased out.

|link_font_color
|<<colors,color>>
|font_color: 428BCA
|font_color: #428bca

|link_font_family
|<<fonts,font family name>>
Expand All @@ -789,7 +790,7 @@ The literal key is used for inline monospaced text in prose and table cells.

|literal_font_color
|<<colors,color>>
|font_color: B12146
|font_color: #b12146

|literal_font_family
|<<fonts,font family name>>
Expand All @@ -812,7 +813,7 @@ The literal key is used for inline monospaced text in prose and table cells.

|heading_font_color
|<<colors,color>>
|font_color: 333333
|font_color: #333333

|heading_font_family
|<<fonts,font family name>>
Expand Down Expand Up @@ -889,7 +890,7 @@ The literal key is used for inline monospaced text in prose and table cells.

|title_page_title_font_color
|<<colors,color>>
|title_font_color: 999999
|title_font_color: #999999

|title_page_title_line_height
|<<values,number>>
Expand Down Expand Up @@ -917,7 +918,7 @@ The literal key is used for inline monospaced text in prose and table cells.

|title_page_authors_font_color
|<<colors,color>>
|authors_font_color: 181818
|authors_font_color: #181818

|title_page_revision_margin_top
|<<measurement-units,measurement>>
Expand Down Expand Up @@ -969,7 +970,7 @@ Block styles are applied to the following block types:

|caption_font_color
|<<colors,color>>
|font_color: 333333
|font_color: #333333

|caption_font_family
|<<fonts,font family name>>
Expand Down Expand Up @@ -1004,7 +1005,7 @@ Block styles are applied to the following block types:

|code_font_color
|<<colors,color>>
|font_color: 333333
|font_color: #333333

|code_font_family
|<<fonts,font family name>>
Expand All @@ -1028,11 +1029,11 @@ Block styles are applied to the following block types:

|code_background_color
|<<colors,color>>
|background_color: F5F5F5
|background_color: #f5f5f5

|code_border_color
|<<colors,color>>
|border_color: CCCCCC
|border_color: #cccccc

|code_border_radius
|<<values,number>>
Expand All @@ -1051,7 +1052,7 @@ Block styles are applied to the following block types:

|blockquote_font_color
|<<colors,color>>
|font_color: 333333
|font_color: #333333

|blockquote_font_family
|<<fonts,font family name>>
Expand All @@ -1071,15 +1072,15 @@ Block styles are applied to the following block types:

|blockquote_border_color
|<<colors,color>>
|border_color: EEEEEE
|border_color: #eeeeee

|blockquote_cite_font_size
|<<values,number>>
|cite_font_size: 9

|blockquote_cite_font_color
|<<colors,color>>
|cite_font_color: 999999
|cite_font_color: #999999

|blockquote_cite_font_family
|<<fonts,font family name>>
Expand All @@ -1099,7 +1100,7 @@ Block styles are applied to the following block types:

|sidebar_border_color
|<<colors,color>>
|border_color: FFFFFF
|border_color: #ffffff

|sidebar_border_radius
|<<values,number>>
Expand All @@ -1111,11 +1112,11 @@ Block styles are applied to the following block types:

|sidebar_background_color
|<<colors,color>>
|background_color: EEEEEE
|background_color: #eeeeee

|sidebar_title_font_color
|<<colors,color>>
|title_font_color: 333333
|title_font_color: #333333

|sidebar_title_font_family
|<<fonts,font family name>>
Expand All @@ -1142,7 +1143,7 @@ Block styles are applied to the following block types:

|example_border_color
|<<colors,color>>
|border_color: EEEEEE
|border_color: #eeeeee

|example_border_radius
|<<values,number>>
Expand All @@ -1154,7 +1155,7 @@ Block styles are applied to the following block types:

|example_background_color
|<<colors,color>>
|background_color: transparent
|background_color: #fffef7
|===

=== Admonition
Expand All @@ -1165,7 +1166,7 @@ Block styles are applied to the following block types:

|admonition_border_color
|<<colors,color>>
|border_color: EEEEEE
|border_color: #eeeeee

|admonition_border_width
|<<values,number>>
Expand Down Expand Up @@ -1206,7 +1207,7 @@ Block styles are applied to the following block types:

|abstract_font_color
|<<colors,color>>
|font_color: 5C6266
|font_color: #5c6266

|abstract_font_size
|<<values,number>>
Expand All @@ -1229,7 +1230,16 @@ Block styles are applied to the following block types:

|thematic_break_border_color
|<<colors,color>>
|border_colorL EEEEEE
|border_color: #eeeeee

|thematic_break_border_style
|solid, double, dashed, dotted +
(default: solid)
|border_style: dashed

|thematic_break_border_width
|<<measurement-units,measurement>>
|border_width: 0.5

|thematic_break_margin_top
|<<measurement-units,measurement>>
Expand Down Expand Up @@ -1279,19 +1289,19 @@ Block styles are applied to the following block types:

|table_background_color
|<<colors,color>>
|background_color: FFFFFF
|background_color: #ffffff

|table_even_row_background_color
|<<colors,color>>
|even_row_background_color: F9F9F9
|even_row_background_color: #f9f9f9

|table_foot_background_color
|<<colors,color>>
|foot_background_color: F0F0F0
|foot_background_color: #f0f0f0

|table_border_color
|<<colors,color>>
|border_color: DDDDDD
|border_color: #dddddd

|table_border_width
|<<values,number>>
Expand All @@ -1315,15 +1325,15 @@ Block styles are applied to the following block types:

|toc_dot_leader_color
|<<colors,color>>
|dot_leader_color: 999999
|dot_leader_color: #999999

|toc_font_color
|<<colors,color>>
|font_color: 333333
|font_color: #333333

|toc_h<n>_font_color
|<<colors,color>>
|h3_font_color: 999999
|h3_font_color: #999999

|toc_font_family
|<<fonts,font family name>>
Expand Down Expand Up @@ -1358,19 +1368,24 @@ Block styles are applied to the following block types:

|header_background_color
|<<colors,color>>
|background_color: EEEEEE
|background_color: #eeeeee

|header_border_color
|<<colors,color>>
|border_color: DDDDDD
|border_color: #dddddd

|header_border_style
|solid, double, dashed, dotted +
(default: solid)
|border_style: dashed

|header_border_width
|<<measurement-units,measurement>>
|border_width: 0.25

|header_font_color
|<<colors,color>>
|font_color: 333333
|font_color: #333333

|header_font_family
|<<fonts,font family name>>
Expand Down Expand Up @@ -1406,19 +1421,24 @@ Block styles are applied to the following block types:

|footer_background_color
|<<colors,color>>
|background_color: EEEEEE
|background_color: #eeeeee

|footer_border_color
|<<colors,color>>
|border_color: DDDDDD
|border_color: #dddddd

|footer_border_style
|solid, double, dashed, dotted +
(default: solid)
|border_style: dashed

|footer_border_width
|<<measurement-units,measurement>>
|border_width: 0.25

|footer_font_color
|<<colors,color>>
|font_color: 333333
|font_color: #333333

|footer_font_family
|<<fonts,font family name>>
Expand Down
11 changes: 6 additions & 5 deletions lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def convert_dlist node
# FIXME extract ensure_space (or similar) method
start_new_page if cursor < @theme.base_line_height_length * (terms.size + 1)
terms.each do |term|
layout_prose term.text, style: @theme.description_list_term_font_style.to_sym, margin_top: 0, margin_bottom: (@theme.vertical_rhythm / 3.0), align: :left
layout_prose term.text, style: (@theme.description_list_term_font_style || :normal).to_sym, margin_top: 0, margin_bottom: (@theme.vertical_rhythm / 3.0), align: :left
end
if desc
indent @theme.description_list_description_indent do
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def convert_table node
def convert_thematic_break node
#move_down @theme.thematic_break_margin_top
theme_margin :thematic_break, :top
stroke_horizontal_rule @theme.thematic_break_border_color, line_width: @theme.thematic_break_border_width
stroke_horizontal_rule @theme.thematic_break_border_color, line_width: @theme.thematic_break_border_width, line_style: (@theme.thematic_break_border_style || :solid).to_sym
#move_down @theme.thematic_break_margin_bottom
theme_margin :thematic_break, :bottom
end
Expand Down Expand Up @@ -1753,6 +1753,7 @@ def layout_running_content position, doc, opts = {}
trim_font_color = @theme.header_font_color || @font_color
trim_bg_color = @theme.header_background_color
trim_border_width = @theme.header_border_width || @theme.base_border_width
trim_border_style = (@theme.header_border_style || :solid).to_sym
trim_border_color = @theme.header_border_color
trim_valign = (@theme.header_valign || :center).to_sym
trim_img_valign = @theme.header_image_valign || trim_valign
Expand All @@ -1766,6 +1767,7 @@ def layout_running_content position, doc, opts = {}
trim_font_color = @theme.footer_font_color || @font_color
trim_bg_color = @theme.footer_background_color
trim_border_width = @theme.footer_border_width || @theme.base_border_width
trim_border_style = (@theme.footer_border_style || :solid).to_sym
trim_border_color = @theme.footer_border_color
trim_valign = (@theme.footer_valign || :center).to_sym
trim_img_valign = @theme.footer_image_valign || trim_valign
Expand All @@ -1790,15 +1792,14 @@ def layout_running_content position, doc, opts = {}
if trim_border_color
# TODO stroke_horizontal_rule should support :at
move_down bounds.height if position == :header
stroke_horizontal_rule trim_border_color, line_width: trim_border_width
stroke_horizontal_rule trim_border_color, line_width: trim_border_width, line_style: trim_border_style
end
end
else
bounding_box [trim_left, trim_top], width: trim_width, height: trim_height do
# TODO stroke_horizontal_rule should support :at
move_down bounds.height if position == :header
stroke_horizontal_rule trim_border_color, line_width: trim_border_width
move_up bounds.height if position == :header
stroke_horizontal_rule trim_border_color, line_width: trim_border_width, line_style: trim_border_style
end
end
end
Expand Down
21 changes: 19 additions & 2 deletions lib/asciidoctor-pdf/prawn_ext/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,26 @@ def stroke_vertical_rule s_color = stroke_color, options = {}
#
def stroke_horizontal_rule s_color = stroke_color, options = {}
save_graphics_state do
line_width options[:line_width] || 0.5
line_width(s_width = options[:line_width] || 0.5)
stroke_color s_color
stroke_horizontal_line bounds.left, bounds.right
case (options[:line_style] || :solid)
when :solid
stroke_horizontal_line bounds.left, bounds.right
when :double
move_up s_width * 1.5
stroke_horizontal_line bounds.left, bounds.right
move_down s_width * 3
stroke_horizontal_line bounds.left, bounds.right
move_up s_width * 1.5
when :dashed
dash s_width * 3
stroke_horizontal_line bounds.left, bounds.right
undash
when :dotted
dash s_width
stroke_horizontal_line bounds.left, bounds.right
undash
end
end
end

Expand Down

0 comments on commit f29b626

Please sign in to comment.