Skip to content

Instantly share code, notes, and snippets.

@ohAitch
Last active August 29, 2015 13:57
Show Gist options
  • Save ohAitch/9718279 to your computer and use it in GitHub Desktop.
Save ohAitch/9718279 to your computer and use it in GitHub Desktop.
A more literal %rune representation, with reemvowelings as annotation.
#require 'jquery'
m= {gl: '<', pr: ')', br: '|', gr: '>', sl: '[', bs: '\\', hx: '#', sm: ';', bc: '$', hp: '-', sr: ']', cb: '_', kl: '{', sg: '~', cn: '%', kr: '}', cl: ':', kt: '^', tr: '*', cm: ',', ls: '+', tc: '`', dq: '"', pm: '&', ts: '=', dt: '.', pt: '@', wt: '?', fs: '/', pl: '(', zp: '!', zy:'Y', zz:'Z'}
m2={gl: 'gal', pr: 'per', br: 'bar', gr: 'gar', sl: 'sel', bs: 'bas', hx: 'hax', sm: 'sem', bc: 'buc', hp: 'hep', sr: 'ser', cb: 'cab', kl: 'kel', sg: 'sig', cn: 'cen', kr: 'ker', sq: 'soq', cl: 'col', kt: 'ket', tr: 'tar', cm: 'com', ls: 'lus', tc: 'tec', dq: 'doq', pm: 'pam', ts: 'tis', dt: 'dot', pt: 'pat', wt: 'wut', fs: 'fas', pl: 'pel', zp: 'zap', zy:'zey', zz:'zaz'}
$('body *').contents().filter ->
@nodeType is 3
.each ->
html = @textContent.replace /%\w{4}\b/g, (s) ->
s1=s[1..2]; s2=s[3..4]
if s1 of m and s2 of m
"%<ruby>'#{m[s1]+m[s2]}'"+
"<rt>#{m2[s1]+m2[s2]}</ruby>"
else
s
if html != @textContent
$(@).replaceWith html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment