class Inkcite::Renderer::Sup
Renders a bulletproof superscript tag. litmus.com/community/discussions/488-best-method-for-superscripts
Constants
- DEFAULT_FONT_SIZE_PERCENT
- DEFAULT_MSO_TEST_RAISE_PERCENT
- MSO_TEXT_RAISE
Name of the CSS style used to force
Public Instance Methods
render(tag, opt, ctx)
click to toggle source
# File lib/inkcite/renderer/sup.rb, line 8 def render tag, opt, ctx html = '' if tag == '/sup' html << '</sup>' else sup = Element.new('sup', :style => { VERTICAL_ALIGN => :top }) font_size = (opt[FONT_SIZE] || DEFAULT_FONT_SIZE_PERCENT).to_i sup.style[FONT_SIZE] = pct(font_size) line_height = (opt[LINE_HEIGHT] || 1).to_i sup.style[LINE_HEIGHT] = line_height mso_text_raise = (font_size.to_f * (DEFAULT_MSO_TEST_RAISE_PERCENT / DEFAULT_FONT_SIZE_PERCENT)).round(0) sup.style[MSO_TEXT_RAISE] = pct(mso_text_raise) html << sup.to_s end html end