diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-04-18 21:11:55 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 21:11:55 -0600 |
| commit | 16404905a911eacb1e2ef521f694b8fd9cd5643e (patch) | |
| tree | 45723edf9986ca580f7ae1c1f9055af4437f41db | |
| parent | 8418082beaf2c4b5d658f1743905770c071b54e2 (diff) | |
resolves #2054 rename blockquote category key in theme to quote (PR #2055)
remap old key with warning for backwards compatibility
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | data/themes/base-theme.yml | 6 | ||||
| -rw-r--r-- | data/themes/default-theme.yml | 18 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 10 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/theme_loader.rb | 2 | ||||
| -rw-r--r-- | spec/abstract_spec.rb | 6 | ||||
| -rw-r--r-- | spec/arrange_block_spec.rb | 8 | ||||
| -rw-r--r-- | spec/paragraph_spec.rb | 2 | ||||
| -rw-r--r-- | spec/quote_spec.rb | 30 | ||||
| -rw-r--r-- | spec/theme_loader_spec.rb | 28 | ||||
| -rw-r--r-- | spec/verse_spec.rb | 2 |
11 files changed, 66 insertions, 47 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6d9f8cbf..26295a2c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -82,6 +82,7 @@ Enhancements:: * extract `arrange_section` method to compute whether section title should be advanced to next page (#2023) * introduce `callout-list` category in theme to control font properties and item spacing of callout lists (#1722) * only indent inner paragraphs (paragraphs that follow an adjacent paragraph) if `prose-inner-text-indent` key is set in theme (#2034) +* rename `blockquote` category key in theme to `quote` and map old `blockquote-` prefix to `quote-` with warning for backwards compatibility (#2054) * rename `key` category key in theme to `kbd` and map old `key-` prefix to `kbd-` with warning for backwards compatibility (#2052) Bug Fixes:: diff --git a/data/themes/base-theme.yml b/data/themes/base-theme.yml index 1d31fcc6..acda717f 100644 --- a/data/themes/base-theme.yml +++ b/data/themes/base-theme.yml @@ -73,9 +73,9 @@ admonition_column_rule_width: 0.5 admonition_padding: [4, 12, 4, 12] admonition_label_font_style: bold admonition_label_text_transform: uppercase -blockquote_border_color: 'EEEEEE' -blockquote_border_left_width: 4 -blockquote_padding: [6, 12, 6, 14] +quote_border_color: 'EEEEEE' +quote_border_left_width: 4 +quote_padding: [6, 12, 6, 14] verse_border_color: 'EEEEEE' verse_border_left_width: 4 verse_padding: [6, 12, 6, 14] diff --git a/data/themes/default-theme.yml b/data/themes/default-theme.yml index 16bec102..5854dd2a 100644 --- a/data/themes/default-theme.yml +++ b/data/themes/default-theme.yml @@ -164,24 +164,24 @@ admonition: label: text_transform: uppercase font_style: bold -blockquote: +quote: font_size: $base_font_size_large border_color: $base_border_color border_width: 0 border_left_width: 5 - padding: [0, $horizontal_rhythm, $block_margin_bottom * 0.25, $horizontal_rhythm + $blockquote_border_left_width / 2] + padding: [0, $horizontal_rhythm, $block_margin_bottom * 0.25, $horizontal_rhythm + $quote_border_left_width / 2] cite: font_size: $base_font_size_small font_color: $role_subtitle_font_color verse: - font_size: $blockquote_font_size - border_color: $blockquote_border_color - border_width: $blockquote_border_width - border_left_width: $blockquote_border_left_width - padding: $blockquote_padding + font_size: $quote_font_size + border_color: $quote_border_color + border_width: $quote_border_width + border_left_width: $quote_border_left_width + padding: $quote_padding cite: - font_size: $blockquote_cite_font_size - font_color: $blockquote_cite_font_color + font_size: $quote_cite_font_size + font_color: $quote_cite_font_color # code is used for source blocks (perhaps change to source or listing?) code: font_color: $base_font_color diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 921c33e8..fc71b009 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -1037,7 +1037,7 @@ module Asciidoctor end def convert_quote_or_verse node - category = node.context == :quote ? :blockquote : :verse + category = node.context == :quote ? :quote : :verse # NOTE: b_width and b_left_width are mutually exclusive if (b_left_width = @theme[%(#{category}_border_left_width)]) && b_left_width > 0 b_color = @theme[%(#{category}_border_color)] @@ -1064,9 +1064,9 @@ module Asciidoctor end pad_box @theme[%(#{category}_padding)] do theme_font category do - if category == :blockquote + if category == :quote traverse node - else # verse + else # :verse content = guard_indentation node.content layout_prose content, normalize: false, align: :left, hyphenate: true, margin_bottom: 0 end @@ -4395,7 +4395,7 @@ module Asciidoctor when 'fill' image_opts[:width] = container_width image_opts[:height] = container_height - else # when 'contain' + else # 'contain' image_opts[:fit] = container_size end elsif (image_width = resolve_explicit_width image_attrs, bounds_width: container_size[0]) @@ -4553,7 +4553,7 @@ module Asciidoctor image_x = bounds.left_side + (bounds.width - image_width) * 0.5 when :right image_x = bounds.right_side - image_width - else # :left or not set + else # :left, nil image_x = bounds.left_side end diff --git a/lib/asciidoctor/pdf/theme_loader.rb b/lib/asciidoctor/pdf/theme_loader.rb index a219a666..df5e7340 100644 --- a/lib/asciidoctor/pdf/theme_loader.rb +++ b/lib/asciidoctor/pdf/theme_loader.rb @@ -14,7 +14,7 @@ module Asciidoctor FontsDir = ::File.join DataDir, 'fonts' BaseThemePath = ::File.join ThemesDir, 'base-theme.yml' BundledThemeNames = (::Dir.children ThemesDir).map {|it| it.slice 0, it.length - 10 } - DeprecatedCategoryKeys = { 'key' => 'kbd', 'outline_list' => 'list' } + DeprecatedCategoryKeys = { 'blockquote' => 'quote', 'key' => 'kbd', 'outline_list' => 'list' } VariableRx = /\$([a-z0-9_-]+)/ LoneVariableRx = /^\$([a-z0-9_-]+)$/ diff --git a/spec/abstract_spec.rb b/spec/abstract_spec.rb index 30330693..75761974 100644 --- a/spec/abstract_spec.rb +++ b/spec/abstract_spec.rb @@ -85,9 +85,9 @@ describe 'Asciidoctor::PDF::Converter - Abstract' do base_line_height: 1, abstract_line_height: 1, abstract_font_size: 10.5, - blockquote_padding: 0, - blockquote_border_left_width: 0, - blockquote_font_size: 10.5, + quote_padding: 0, + quote_border_left_width: 0, + quote_font_size: 10.5, heading_h2_font_size: 10.5, heading_margin_top: 0, heading_margin_bottom: 12, diff --git a/spec/arrange_block_spec.rb b/spec/arrange_block_spec.rb index 4bbbdbb0..0b8bacb5 100644 --- a/spec/arrange_block_spec.rb +++ b/spec/arrange_block_spec.rb @@ -107,10 +107,10 @@ describe 'Asciidoctor::PDF::Converter#arrange_block' do admonition_border_color: 'EEEEEE', admonition_border_width: 0.5, admonition_padding: 12, - blockquote_border_width: 0.5, - blockquote_border_left_width: 0, - blockquote_font_size: 10.5, - blockquote_padding: 12, + quote_border_width: 0.5, + quote_border_left_width: 0, + quote_font_size: 10.5, + quote_padding: 12, code_padding: 12, } %w(==== **** ____ ---- .... [NOTE]==== example sidebar quote NOTE).each do |style| diff --git a/spec/paragraph_spec.rb b/spec/paragraph_spec.rb index 05ee38b8..1062d876 100644 --- a/spec/paragraph_spec.rb +++ b/spec/paragraph_spec.rb @@ -92,7 +92,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do #{lorem_ipsum '2-sentences-1-paragraph'} - > blockquote + > quote #{lorem_ipsum '2-sentences-1-paragraph'} diff --git a/spec/quote_spec.rb b/spec/quote_spec.rb index 665f4fe5..a0a0c911 100644 --- a/spec/quote_spec.rb +++ b/spec/quote_spec.rb @@ -102,7 +102,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do end it 'should not draw left border if border_left_width is 0' do - pdf = to_pdf <<~'EOS', pdf_theme: { blockquote_border_left_width: 0 }, analyze: :line + pdf = to_pdf <<~'EOS', pdf_theme: { quote_border_left_width: 0 }, analyze: :line ____ Let it be. ____ @@ -112,7 +112,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do end it 'should not draw left border if border_left_width is nil' do - pdf = to_pdf <<~'EOS', pdf_theme: { blockquote_border_left_width: nil, blockquote_border_width: nil }, analyze: :line + pdf = to_pdf <<~'EOS', pdf_theme: { quote_border_left_width: nil, quote_border_width: nil }, analyze: :line ____ Let it be. ____ @@ -147,8 +147,8 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should apply specified background color', visual: true do pdf_theme = { - blockquote_background_color: 'dddddd', - blockquote_border_color: 'aa0000', + quote_background_color: 'dddddd', + quote_border_color: 'aa0000', } to_file = to_pdf_file <<~'EOS', 'quote-background-color.pdf', pdf_theme: pdf_theme ____ @@ -162,11 +162,11 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should apply specified border and background color', visual: true do pdf_theme = build_pdf_theme \ - blockquote_border_left_width: 0, - blockquote_border_width: 0.5, - blockquote_border_color: 'aa0000', - blockquote_background_color: 'dddddd' - pdf_theme.blockquote_padding = pdf_theme.sidebar_padding + quote_border_left_width: 0, + quote_border_width: 0.5, + quote_border_color: 'aa0000', + quote_background_color: 'dddddd' + pdf_theme.quote_padding = pdf_theme.sidebar_padding to_file = to_pdf_file <<~'EOS', 'quote-border-and-background-color.pdf', pdf_theme: pdf_theme [,Paul McCartney] ____ @@ -226,11 +226,11 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should split border when block is split across pages', visual: true do pdf_theme = { - blockquote_border_left_width: 0, - blockquote_border_width: 0.5, - blockquote_border_color: 'CCCCCC', - blockquote_background_color: 'EEEEEE', - blockquote_padding: [6, 10, 12, 10], + quote_border_left_width: 0, + quote_border_width: 0.5, + quote_border_color: 'CCCCCC', + quote_background_color: 'EEEEEE', + quote_padding: [6, 10, 12, 10], } to_file = to_pdf_file <<~EOS, 'quote-page-split.pdf', pdf_theme: pdf_theme ____ @@ -264,7 +264,7 @@ describe 'Asciidoctor::PDF::Converter - Quote' do it 'should keep caption with block and draw border across extent if only caption fits on current page' do block_content = ['text of quote'] * 15 * %(\n\n) - pdf_theme = { prose_margin_bottom: 12, blockquote_padding: [0, 0, 0, 15] } + pdf_theme = { prose_margin_bottom: 12, quote_padding: [0, 0, 0, 15] } with_content_spacer 10, 690 do |spacer_path| input = <<~EOS before diff --git a/spec/theme_loader_spec.rb b/spec/theme_loader_spec.rb index 69b385ec..a1e5bbd6 100644 --- a/spec/theme_loader_spec.rb +++ b/spec/theme_loader_spec.rb @@ -168,11 +168,29 @@ describe Asciidoctor::PDF::ThemeLoader do (expect theme).to be_an OpenStruct (expect theme.outline_list_item_spacing).to be_nil (expect theme.list_item_spacing).to eql 6 - (expect theme.footnotes_margin_top).to eql 6 + (expect theme.footnotes_margin_top).to eql theme.list_item_spacing (expect theme.footnotes_item_spacing).to eql 3 end).to log_message severity: :WARN, message: 'the outline-list theme category is deprecated; use the list category instead' end + it 'should remap blockquote category to quote category and warn' do + (expect do + theme_data = YAML.safe_load <<~'EOS' + blockquote: + font-color: 4A4A4A + border-color: $blockquote-font-color + verse: + font-color: $blockquote-font-color + EOS + theme = subject.new.load theme_data + (expect theme).to be_an OpenStruct + (expect theme.blockquote_font_color).to be_nil + (expect theme.quote_font_color).to eql '4A4A4A' + (expect theme.quote_border_color).to eql theme.quote_font_color + (expect theme.verse_font_color).to eql theme.quote_font_color + end).to log_message severity: :WARN, message: 'the blockquote theme category is deprecated; use the quote category instead' + end + it 'should remap key category to kbd category and warn' do (expect do theme_data = YAML.safe_load <<~'EOS' @@ -185,7 +203,7 @@ describe Asciidoctor::PDF::ThemeLoader do (expect theme).to be_an OpenStruct (expect theme.key_border_color).to be_nil (expect theme.kbd_border_color).to eql 'CCCCCC' - (expect theme.kbd_font_color).to eql 'CCCCCC' + (expect theme.kbd_font_color).to eql theme.kbd_border_color end).to log_message severity: :WARN, message: 'the key theme category is deprecated; use the kbd category instead' end @@ -1184,16 +1202,16 @@ describe Asciidoctor::PDF::ThemeLoader do font_size_large: $base_font_size * 1.25 font_size_min: $base_font_size * 3 / 4 border_radius: 3 ^ 2 - blockquote: + quote: border_width: 5 - padding: [0, $base_line_height_length - 2, $base_line_height_length * -0.75, $base_line_height_length + $blockquote_border_width / 2] + padding: [0, $base_line_height_length - 2, $base_line_height_length * -0.75, $base_line_height_length + $quote_border_width / 2] EOS theme = subject.new.load theme_data (expect theme.base_line_height).to eql 1.2 (expect theme.base_font_size_large).to eql 12.5 (expect theme.base_font_size_min).to eql 7.5 (expect theme.base_border_radius).to eql 9 - (expect theme.blockquote_padding).to eql [0, 10, -9, 14.5] + (expect theme.quote_padding).to eql [0, 10, -9, 14.5] end it 'should coerce value to numeric if negated variable is a number' do diff --git a/spec/verse_spec.rb b/spec/verse_spec.rb index 20ef09f9..a2400195 100644 --- a/spec/verse_spec.rb +++ b/spec/verse_spec.rb @@ -134,7 +134,7 @@ describe 'Asciidoctor::PDF::Converter - Verse' do verse_border_width: 0.5, verse_border_color: 'aa0000', verse_background_color: 'dddddd' - pdf_theme.blockquote_padding = pdf_theme.sidebar_padding + pdf_theme.quote_padding = pdf_theme.sidebar_padding to_file = to_pdf_file <<~'EOS', 'verse-border-and-background-color.pdf', pdf_theme: pdf_theme [verse,Paul McCartney] ____ |
