mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-11 15:13:25 +08:00
Cast rgb() formatted css colors to hex for DOCX [SCI-7796]
This commit is contained in:
parent
58be66a06c
commit
0304daef7d
1 changed files with 8 additions and 2 deletions
|
@ -202,8 +202,8 @@ module Reports
|
|||
|
||||
if key == 'text-align'
|
||||
result[:align] = value.to_sym
|
||||
elsif key == 'color' && Reports::Utils.calculate_color_hsp(value) < 190
|
||||
result[:color] = value.delete('#')
|
||||
elsif key == 'color' && Reports::Utils.calculate_color_hsp("##{normalized_hex_color(value)}") < 190
|
||||
result[:color] = normalized_hex_color(value)
|
||||
elsif key == 'text-decoration' && value == 'underline'
|
||||
result[:underline] = true
|
||||
end
|
||||
|
@ -269,5 +269,11 @@ module Reports
|
|||
def text_formatting_element(element)
|
||||
{ type: element.name, value: element.text }
|
||||
end
|
||||
|
||||
def normalized_hex_color(color)
|
||||
return color.delete('#') if color.start_with?('#')
|
||||
|
||||
color.scan(/\d+/).map(&:to_i).map { |c| c.to_s(16).rjust(2, '0').upcase }.join
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue