summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-04-15 15:47:25 -0600
committerGitHub <noreply@github.com>2022-04-15 15:47:25 -0600
commit3787b0dacdefdb376427e13cd53e82e8b1af2288 (patch)
treec2d56c5861c3151d5dbde10954fbf02df749bade
parentc6a9df19238c4cdccbd909bac7ce200dff08be80 (diff)
resolves #2031 change lead category in theme to built-in role named lead (PR #2033)
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--data/themes/base-theme.yml3
-rw-r--r--data/themes/default-theme.yml6
-rw-r--r--docs/theming-guide.adoc55
-rw-r--r--lib/asciidoctor/pdf/converter.rb4
-rw-r--r--spec/paragraph_spec.rb2
-rw-r--r--spec/preamble_spec.rb4
7 files changed, 11 insertions, 64 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 32701c96..1d6660f1 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -24,6 +24,7 @@ Enhancements::
* allow theme to control font color of first line of abstract
* allow theme to control background color and border offset (only for background) for links (#1705)
* support custom role on paragraph to allow theme to control font properties (#483)
+* change lead category in theme to built-in role named lead (#2031)
* don't render index section if index is empty (i.e., there are no index entries)
* allow title of special section to be hidden by setting `untitled` option on section
* stabilize font paths in built-in themes by prefixing paths with GEM_FONTS_DIR (#1568)
diff --git a/data/themes/base-theme.yml b/data/themes/base-theme.yml
index f1a889b5..fcc82ff7 100644
--- a/data/themes/base-theme.yml
+++ b/data/themes/base-theme.yml
@@ -19,6 +19,7 @@ base_font_style: normal
base_line_height: 1.15
base_border_color: 'EEEEEE'
base_border_width: 0.5
+role_lead_font_size: 13.5
role_line-through_text_decoration: line-through
role_underline_text_decoration: underline
role_big_font_size: 14
@@ -92,8 +93,6 @@ example_border_color: 'EEEEEE'
example_border_width: 0.5
example_padding: 12
image_align: left
-lead_font_size: 13.5
-lead_line_height: 1.4
prose_margin_bottom: 12
sidebar_background_color: 'EEEEEE'
sidebar_padding: 12
diff --git a/data/themes/default-theme.yml b/data/themes/default-theme.yml
index af3e2a9b..f55a717e 100644
--- a/data/themes/default-theme.yml
+++ b/data/themes/default-theme.yml
@@ -53,6 +53,8 @@ base:
border_radius: 4
border_width: 0.5
role:
+ lead:
+ font_size: $base_font_size_large
line-through:
text_decoration: line-through
underline:
@@ -139,11 +141,9 @@ caption:
# FIXME perhaps set line_height instead of / in addition to margins?
margin_inside: $vertical_rhythm / 3
margin_outside: 0
-lead:
- font_size: $base_font_size_large
abstract:
font_color: 5C6266
- font_size: $lead_font_size
+ font_size: $role_lead_font_size
line_height: 1.4
font_style: italic
first_line_font_style: bold
diff --git a/docs/theming-guide.adoc b/docs/theming-guide.adoc
index 023a8d08..3e016548 100644
--- a/docs/theming-guide.adoc
+++ b/docs/theming-guide.adoc
@@ -1184,6 +1184,7 @@ This role can be used as follows:
----
The converter provides several predefined roles, which can can all be redefined.
+The `lead` defines the font properties for a lead paragraph, whether the role is assign implicitly or explicitly.
The `big` and `small` roles map the font size to the $base-font-size-large and $base-font-size-small values, respectively.
The `underline` and `line-through` roles add the underline and strikethrough decorations, respectively.
The `subtitle` role is used to configure the font properties of the subtitle of a section title.
@@ -3711,60 +3712,6 @@ The keys in this category control the SVG integration.
1. The fallback font family is only used when the font family in the SVG does not map to a known font name from the font catalog.
-[#keys-lead]
-=== Lead
-
-The keys in this category control the styling of lead paragraphs.
-
-[cols="3,4,5l"]
-|===
-|Key |Value Type |Example
-
-3+|[#key-prefix-lead]*Key Prefix:* <<key-prefix-lead,lead>>
-
-|font-color
-|<<colors,Color>> +
-(default: _inherit_)
-|lead:
- font-color: #262626
-
-|font-family
-|<<fonts,Font family name>> +
-(default: _inherit_)
-|lead:
- font-family: M+ 1p
-
-|font-kerning
-|normal {vbar} none +
-(default: _inherit_)
-|lead:
- font-kerning: none
-
-|font-size
-|<<values,Number>> +
-(default: 13.5)
-|lead:
- font-size: 13
-
-|font-style
-|<<font-styles,Font style>> +
-(default: _inherit_)
-|lead:
- font-style: bold
-
-|text-transform
-|<<text-transforms,Text transform>> +
-(default: _inherit_)
-|lead:
- text-transform: uppercase
-
-|line-height
-|<<values,Number>> +
-(default: 1.4)
-|lead:
- line-height: 1.4
-|===
-
[#keys-abstract]
=== Abstract
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb
index 169bd8f6..47a06589 100644
--- a/lib/asciidoctor/pdf/converter.rb
+++ b/lib/asciidoctor/pdf/converter.rb
@@ -822,8 +822,8 @@ module Asciidoctor
if roles.empty?
layout_prose node.content, prose_opts
else
- prose_opts[:line_height] = @theme.lead_line_height if roles.include? 'lead'
- theme_font_cascade (roles.map {|role| role == 'lead' ? :lead : %(role_#{role}).to_sym }) do
+ prose_opts[:line_height] = @theme.role_lead_line_height if roles.include? 'lead'
+ theme_font_cascade (roles.map {|role| %(role_#{role}).to_sym }) do
layout_prose node.content, prose_opts
end
end
diff --git a/spec/paragraph_spec.rb b/spec/paragraph_spec.rb
index ce4dc075..02f0a2e5 100644
--- a/spec/paragraph_spec.rb
+++ b/spec/paragraph_spec.rb
@@ -149,7 +149,7 @@ describe 'Asciidoctor::PDF::Converter - Paragraph' do
reference_texts = (to_pdf input, analyze: true).text
default_spacing = reference_texts[0][:y] - reference_texts[1][:y]
- texts = (to_pdf input, pdf_theme: { lead_line_height: 2 }, analyze: true).text
+ texts = (to_pdf input, pdf_theme: { role_lead_line_height: 2 }, analyze: true).text
adjusted_spacing = texts[0][:y] - texts[1][:y]
(expect adjusted_spacing).to be > default_spacing
diff --git a/spec/preamble_spec.rb b/spec/preamble_spec.rb
index 3c805860..5a8d3fa4 100644
--- a/spec/preamble_spec.rb
+++ b/spec/preamble_spec.rb
@@ -239,8 +239,8 @@ describe 'Asciidoctor::PDF::Converter - Preamble' do
context 'theming' do
it 'should allow theme to customize style of lead paragraph' do
pdf_theme = {
- lead_font_size: 14,
- lead_font_color: '000000',
+ role_lead_font_size: 14,
+ role_lead_font_color: '000000',
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
= Document Title