mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Fix superscript and subscript in docx report generator [SCI-7141]
This commit is contained in:
parent
13b085bc9d
commit
922652417a
2 changed files with 27 additions and 1 deletions
|
@ -13,6 +13,14 @@ module Reports
|
|||
br
|
||||
elsif text_el[:type] == 'a'
|
||||
Reports::DocxRenderer.render_link_element(self, text_el, options)
|
||||
elsif text_el[:type] == 'sup'
|
||||
text text_el[:value] do
|
||||
vertical_align 'superscript'
|
||||
end
|
||||
elsif text_el[:type] == 'sub'
|
||||
text text_el[:value] do
|
||||
vertical_align 'subscript'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ module Reports
|
|||
temp_p = []
|
||||
end
|
||||
elements.push(elem)
|
||||
elsif %w(br text a).include? elem[:type]
|
||||
elsif %w(br text a sup sub).include? elem[:type]
|
||||
temp_p.push(elem)
|
||||
end
|
||||
end
|
||||
|
@ -106,6 +106,16 @@ module Reports
|
|||
next
|
||||
end
|
||||
|
||||
if elem.name == 'sup'
|
||||
elements.push(sup_element(elem))
|
||||
next
|
||||
end
|
||||
|
||||
if elem.name == 'sub'
|
||||
elements.push(sub_element(elem))
|
||||
next
|
||||
end
|
||||
|
||||
if %w(ul ol).include?(elem.name)
|
||||
elements.push(list_element(elem))
|
||||
next
|
||||
|
@ -257,5 +267,13 @@ module Reports
|
|||
end.reject(&:blank?)
|
||||
{ type: 'table', data: rows }
|
||||
end
|
||||
|
||||
def sup_element(element)
|
||||
{ type: 'sup', value: element.text }
|
||||
end
|
||||
|
||||
def sub_element(element)
|
||||
{ type: 'sub', value: element.text }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue