From fea122746deb6013aa0517b567f7f9b68aa7f26d Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 14 Jun 2015 22:45:02 -0600 Subject: [PATCH] resolves #196 add support for border style - add support for line_style to stroke_horizontal_rule method - allow border style to be set for running header/footer and thematic break - document new keys - lowercase all color values and prefix with # in theming guide --- docs/theming-guide.adoc | 92 +++++++++++++-------- lib/asciidoctor-pdf/converter.rb | 11 +-- lib/asciidoctor-pdf/prawn_ext/extensions.rb | 21 ++++- 3 files changed, 81 insertions(+), 43 deletions(-) diff --git a/docs/theming-guide.adoc b/docs/theming-guide.adoc index 9c8258867..4c7bc6317 100644 --- a/docs/theming-guide.adoc +++ b/docs/theming-guide.adoc @@ -662,14 +662,15 @@ TBW |page_background_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 @@ -733,7 +734,7 @@ TBW |base_border_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. @@ -765,7 +766,7 @@ These keys predated the CSS-style theme system and are planned to be phased out. |link_font_color |<> -|font_color: 428BCA +|font_color: #428bca |link_font_family |<> @@ -790,7 +791,7 @@ The literal key is used for inline monospaced text in prose and table cells. |literal_font_color |<> -|font_color: B12146 +|font_color: #b12146 |literal_font_family |<> @@ -813,7 +814,7 @@ The literal key is used for inline monospaced text in prose and table cells. |heading_font_color |<> -|font_color: 333333 +|font_color: #333333 |heading_font_family |<> @@ -890,7 +891,7 @@ The literal key is used for inline monospaced text in prose and table cells. |title_page_title_font_color |<> -|title_font_color: 999999 +|title_font_color: #999999 |title_page_title_line_height |<> @@ -918,7 +919,7 @@ The literal key is used for inline monospaced text in prose and table cells. |title_page_authors_font_color |<> -|authors_font_color: 181818 +|authors_font_color: #181818 |title_page_revision_margin_top |<> @@ -970,7 +971,7 @@ Block styles are applied to the following block types: |caption_font_color |<> -|font_color: 333333 +|font_color: #333333 |caption_font_family |<> @@ -1005,7 +1006,7 @@ Block styles are applied to the following block types: |code_font_color |<> -|font_color: 333333 +|font_color: #333333 |code_font_family |<> @@ -1029,11 +1030,11 @@ Block styles are applied to the following block types: |code_background_color |<> -|background_color: F5F5F5 +|background_color: #f5f5f5 |code_border_color |<> -|border_color: CCCCCC +|border_color: #cccccc |code_border_radius |<> @@ -1052,7 +1053,7 @@ Block styles are applied to the following block types: |blockquote_font_color |<> -|font_color: 333333 +|font_color: #333333 |blockquote_font_family |<> @@ -1072,7 +1073,7 @@ Block styles are applied to the following block types: |blockquote_border_color |<> -|border_color: EEEEEE +|border_color: #eeeeee |blockquote_cite_font_size |<> @@ -1080,7 +1081,7 @@ Block styles are applied to the following block types: |blockquote_cite_font_color |<> -|cite_font_color: 999999 +|cite_font_color: #999999 |blockquote_cite_font_family |<> @@ -1100,7 +1101,7 @@ Block styles are applied to the following block types: |sidebar_border_color |<> -|border_color: FFFFFF +|border_color: #ffffff |sidebar_border_radius |<> @@ -1112,11 +1113,11 @@ Block styles are applied to the following block types: |sidebar_background_color |<> -|background_color: EEEEEE +|background_color: #eeeeee |sidebar_title_font_color |<> -|title_font_color: 333333 +|title_font_color: #333333 |sidebar_title_font_family |<> @@ -1143,7 +1144,7 @@ Block styles are applied to the following block types: |example_border_color |<> -|border_color: EEEEEE +|border_color: #eeeeee |example_border_radius |<> @@ -1155,7 +1156,7 @@ Block styles are applied to the following block types: |example_background_color |<> -|background_color: transparent +|background_color: #fffef7 |=== === Admonition @@ -1166,7 +1167,7 @@ Block styles are applied to the following block types: |admonition_border_color |<> -|border_color: EEEEEE +|border_color: #eeeeee |admonition_border_width |<> @@ -1207,7 +1208,7 @@ Block styles are applied to the following block types: |abstract_font_color |<> -|font_color: 5C6266 +|font_color: #5c6266 |abstract_font_size |<> @@ -1230,7 +1231,16 @@ Block styles are applied to the following block types: |thematic_break_border_color |<> -|border_colorL EEEEEE +|border_color: #eeeeee + +|thematic_break_border_style +|solid, double, dashed, dotted + +(default: solid) +|border_style: dashed + +|thematic_break_border_width +|<> +|border_width: 0.5 |thematic_break_margin_top |<> @@ -1280,19 +1290,19 @@ Block styles are applied to the following block types: |table_background_color |<> -|background_color: FFFFFF +|background_color: #ffffff |table_even_row_background_color |<> -|even_row_background_color: F9F9F9 +|even_row_background_color: #f9f9f9 |table_foot_background_color |<> -|foot_background_color: F0F0F0 +|foot_background_color: #f0f0f0 |table_border_color |<> -|border_color: DDDDDD +|border_color: #dddddd |table_border_width |<> @@ -1316,15 +1326,15 @@ Block styles are applied to the following block types: |toc_dot_leader_color |<> -|dot_leader_color: 999999 +|dot_leader_color: #999999 |toc_font_color |<> -|font_color: 333333 +|font_color: #333333 |toc_h_font_color |<> -|h3_font_color: 999999 +|h3_font_color: #999999 |toc_font_family |<> @@ -1359,11 +1369,16 @@ Block styles are applied to the following block types: |header_background_color |<> -|background_color: EEEEEE +|background_color: #eeeeee |header_border_color |<> -|border_color: DDDDDD +|border_color: #dddddd + +|header_border_style +|solid, double, dashed, dotted + +(default: solid) +|border_style: dashed |header_border_width |<> @@ -1371,7 +1386,7 @@ Block styles are applied to the following block types: |header_font_color |<> -|font_color: 333333 +|font_color: #333333 |header_font_family |<> @@ -1407,11 +1422,16 @@ Block styles are applied to the following block types: |footer_background_color |<> -|background_color: EEEEEE +|background_color: #eeeeee |footer_border_color |<> -|border_color: DDDDDD +|border_color: #dddddd + +|footer_border_style +|solid, double, dashed, dotted + +(default: solid) +|border_style: dashed |footer_border_width |<> @@ -1419,7 +1439,7 @@ Block styles are applied to the following block types: |footer_font_color |<> -|font_color: 333333 +|font_color: #333333 |footer_font_family |<> diff --git a/lib/asciidoctor-pdf/converter.rb b/lib/asciidoctor-pdf/converter.rb index e5442b542..e22bca518 100644 --- a/lib/asciidoctor-pdf/converter.rb +++ b/lib/asciidoctor-pdf/converter.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/lib/asciidoctor-pdf/prawn_ext/extensions.rb b/lib/asciidoctor-pdf/prawn_ext/extensions.rb index c71b60734..d6b26d980 100644 --- a/lib/asciidoctor-pdf/prawn_ext/extensions.rb +++ b/lib/asciidoctor-pdf/prawn_ext/extensions.rb @@ -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