summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-07-20 17:25:20 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-07-20 17:25:20 -0600
commit92b854bcc51426ff3bc038837f5fb978c9db8987 (patch)
tree9fe7b6f9ae9cd2a88f09ef64acaad81b5baa649d
parent9e300c596061d2d0b71863e11a5dccd5af2a43f1 (diff)
allow theme to control font style of marker (per marker or all markers) for unordered list
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--docs/modules/theme/pages/list.adoc27
-rw-r--r--lib/asciidoctor/pdf/converter.rb2
-rw-r--r--spec/list_spec.rb84
4 files changed, 73 insertions, 41 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index a52a95c6..c54b33c0 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -19,6 +19,7 @@ Enhancements::
* add `--sourcemap` option to CLI to enable `:sourcemap` option on processor (#2265)
* broaden support for relative font sizes in theme to more than just inline elements; document support for relative font sizes
* allow theme to control font properties of marker for ordered list using `olist-marker` category (#2279)
+* allow theme to control font style of marker (per marker or all markers) for unordered list
Improvements::
diff --git a/docs/modules/theme/pages/list.adoc b/docs/modules/theme/pages/list.adoc
index 342e19df..87f939b2 100644
--- a/docs/modules/theme/pages/list.adoc
+++ b/docs/modules/theme/pages/list.adoc
@@ -77,6 +77,14 @@ olist:
marker:
font-color: #CCCCCC
+|font-style
+|xref:text.adoc#font-style[Font style] +
+(default: `$base-font-style`)
+|[source]
+olist:
+ marker:
+ font-style: bold
+
|line-height
|xref:language.adoc#values[Number] +
(default: `$base-line-height`)
@@ -119,6 +127,14 @@ ulist:
marker:
font-color: #CCCCCC
+|font-style
+|xref:text.adoc#font-style[Font style] +
+(default: `$base-font-style`)
+|[source]
+ulist:
+ marker:
+ font-style: bold
+
|line-height
|xref:language.adoc#values[Number] +
(default: `$base-line-height`)
@@ -170,9 +186,18 @@ ulist:
|[source]
ulist:
marker:
- disc:
+ square:
font-color: #FF0000
+|font-style
+|xref:text.adoc#font-style[Font style] +
+(default: _inherit_)
+|[source]
+ulist:
+ marker:
+ circle:
+ font-style: bold
+
|line-height
|xref:language.adoc#values[Number] +
(default: _inherit_)
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb
index b6b58214..1ffe7ccb 100644
--- a/lib/asciidoctor/pdf/converter.rb
+++ b/lib/asciidoctor/pdf/converter.rb
@@ -1622,7 +1622,7 @@ module Asciidoctor
else
marker = @theme[%(ulist_marker_#{marker_type}_content)] || Bullets[marker_type]
end
- [:font_color, :font_family, :font_size, :line_height].each do |prop|
+ [:font_color, :font_family, :font_size, :font_style, :line_height].each do |prop|
marker_style[prop] = @theme[%(ulist_marker_#{marker_type}_#{prop})] || @theme[%(ulist_marker_#{prop})] || marker_style[prop]
end if marker
end
diff --git a/spec/list_spec.rb b/spec/list_spec.rb
index d4301eb2..433557ae 100644
--- a/spec/list_spec.rb
+++ b/spec/list_spec.rb
@@ -215,37 +215,16 @@ describe 'Asciidoctor::PDF::Converter - List' do
end
it 'should allow theme to change marker color for ulist' do
- pdf_theme = { ulist_marker_font_color: '00FF00' }
-
- pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
- * all
- * the
- * things
- EOS
-
- marker_colors = (pdf.find_text ?\u2022).map {|it| it[:font_color] }.uniq
- (expect marker_colors).to eql ['00FF00']
- end
-
- it 'should allow theme to change marker color for any list' do
- pdf_theme = { list_marker_font_color: '00FF00' }
-
- pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
- * all
- * the
- * things
-
- //
-
- . pencil
- . paper
- . thoughts
- EOS
+ [:list_marker_font_color, :ulist_marker_font_color].each do |key|
+ pdf = to_pdf <<~'EOS', pdf_theme: { key => '00FF00' }, analyze: true
+ * all
+ * the
+ * things
+ EOS
- ulist_marker_colors = (pdf.find_text ?\u2022).map {|it| it[:font_color] }.uniq
- olist_marker_colors = (pdf.find_text %r/[1-3]\./).map {|it| it[:font_color] }.uniq
- (expect ulist_marker_colors).to eql ['00FF00']
- (expect olist_marker_colors).to eql ['00FF00']
+ marker_colors = (pdf.find_text ?\u2022).map {|it| it[:font_color] }.uniq
+ (expect marker_colors).to eql ['00FF00']
+ end
end
it 'should allow theme to change marker font size, font family, and line height for ulist' do
@@ -269,6 +248,33 @@ describe 'Asciidoctor::PDF::Converter - List' do
(expect marker[:y]).to be < text[:y]
end
+ it 'should allow theme to change marker font style for ulist' do
+ pdf_theme = { ulist_marker_font_style: 'bold' }
+
+ pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
+ * one
+ * two
+ * three
+ EOS
+
+ marker = (pdf.find_text ?\u2022)[0]
+ (expect marker[:font_name]).to eql 'NotoSerif-Bold'
+ end
+
+ it 'should allow theme to change specific marker font style for ulist' do
+ pdf_theme = { ulist_marker_circle_font_style: 'bold' }
+
+ pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
+ [circle]
+ * one
+ * two
+ * three
+ EOS
+
+ marker = (pdf.find_text ?\u25e6)[0]
+ (expect marker[:font_name]).to eql 'NotoSerif-Bold'
+ end
+
it 'should reserve enough space for marker that is not found in any font' do
pdf_theme = {
extends: 'default-with-font-fallbacks',
@@ -632,16 +638,16 @@ describe 'Asciidoctor::PDF::Converter - List' do
end
it 'should allow theme to change marker color for olist' do
- pdf_theme = { olist_marker_font_color: '00FF00' }
-
- pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
- . one
- . two
- . three
- EOS
+ [:list_marker_font_color, :olist_marker_font_color].each do |key|
+ pdf = to_pdf <<~'EOS', pdf_theme: { key => '00FF00' }, analyze: true
+ . one
+ . two
+ . three
+ EOS
- marker_colors = (pdf.find_text %r/\d\./).map {|it| it[:font_color] }.uniq
- (expect marker_colors).to eql ['00FF00']
+ marker_colors = (pdf.find_text %r/\d\./).map {|it| it[:font_color] }.uniq
+ (expect marker_colors).to eql ['00FF00']
+ end
end
it 'should allow theme to change marker font size, font family, and line height for olist' do