src/js/locale/h-ruby.js
function renderSimpleRuby( $ruby ) {
  var frag = $.create( '!' )
  var clazz = $ruby.classList
  var $rb, $ru

  frag.appendChild( $.clone( $ruby ))

  $
  .tag( 'rt', frag.firstChild )
  .forEach(function( $rt ) {
    var $rb = $.create( '!' )
    var airb = []
    var irb

    // Consider the previous nodes the implied
    // ruby base
    do {
      irb = ( irb || $rt ).previousSibling
      if ( !irb || irb.nodeName.match( /((?:h\-)?r[ubt])/i ))  break

      $rb.insertBefore( $.clone( irb ), $rb.firstChild )
      airb.push( irb )
    } while ( !irb.nodeName.match( /((?:h\-)?r[ubt])/i ))

    // Create a real `<h-ru>` to append.
    $ru = clazz.contains( 'zhuyin' ) ? createZhuyinRu( $rb, $rt ) : createNormalRu( $rb, $rt )

    // Replace the ruby text with the new `<h-ru>`,
    // and remove the original implied ruby base(s)
    try {
      $rt.parentNode.replaceChild( $ru, $rt )
      airb.map( $.remove )
    } catch ( e ) {}
  })
  return createCustomRuby( frag )
}
function renderSimpleRuby( $ruby ) {
  var frag = $.create( '!' )
  var clazz = $ruby.classList
  var $rb, $ru

  frag.appendChild( $.clone( $ruby ))

  $
  .tag( 'rt', frag.firstChild )
  .forEach(function( $rt ) {
    var $rb = $.create( '!' )
    var airb = []
    var irb

    // Consider the previous nodes the implied
    // ruby base
    do {
      irb = ( irb || $rt ).previousSibling
      if ( !irb || irb.nodeName.match( /((?:h\-)?r[ubt])/i ))  break

      $rb.insertBefore( $.clone( irb ), $rb.firstChild )
      airb.push( irb )
    } while ( !irb.nodeName.match( /((?:h\-)?r[ubt])/i ))

    // Create a real `<h-ru>` to append.
    $ru = clazz.contains( 'zhuyin' ) ? createZhuyinRu( $rb, $rt ) : createNormalRu( $rb, $rt )

    // Replace the ruby text with the new `<h-ru>`,
    // and remove the original implied ruby base(s)
    try {
      $rt.parentNode.replaceChild( $ru, $rt )
      airb.map( $.remove )
    } catch ( e ) {}
  })
  return createCustomRuby( frag )
}
function renderSimpleRuby ( $ruby ) { var frag = $ . create ( '!' ) var clazz = $ruby . classList var $rb , $ru frag . appendChild ( $ . clone ( $ruby ) ) $ . tag ( 'rt' , frag . firstChild ) . forEach ( function ( $rt ) { var $rb = $ . create ( '!' ) var airb = [ ] var irb // Consider the previous nodes the implied // ruby base do { irb = ( irb || $rt ) . previousSibling if ( ! irb || irb . nodeName . match ( / ((?:h\-)?r[ubt]) / i ) ) break $rb . insertBefore ( $ . clone ( irb ) , $rb . firstChild ) airb . push ( irb ) } while ( ! irb . nodeName . match ( / ((?:h\-)?r[ubt]) / i ) ) // Create a real `<h-ru>` to append. $ru = clazz . contains ( 'zhuyin' ) ? createZhuyinRu ( $rb , $rt ) : createNormalRu ( $rb , $rt ) // Replace the ruby text with the new `<h-ru>`, // and remove the original implied ruby base(s) try { $rt . parentNode . replaceChild ( $ru , $rt ) airb . map ( $ . remove ) } catch ( e ) { } } ) return createCustomRuby ( frag ) }
1. Simple ruby polyfill; 2. Inter-character polyfill for Zhuyin
1 . Simple ruby polyfill ; 2 . Inter - character polyfill for Zhuyin