2 window.walk = (node, handler) ->
4 textHandler = handler.text
10 child = node.firstChild
12 nxt = child.nextSibling
19 window.wrapInTag = (regex, tagName) ->
22 while m = regex.exec(node.nodeValue)
23 matches.push [regex.lastIndex, m[0]]
29 frm = m[0] - m[1].length
31 node_rest = node.splitText(to)
32 alien = node.splitText(frm)
33 wrapper = node.ownerDocument.createElement tagName
34 node.parentNode.insertBefore wrapper, node_rest
35 wrapper.appendChild alien
39 # window._test_xml_tools = ->
41 # dom = p.parseFromString("<a><b>łuków</b><c>jakaś jeszcze ~</c></a>", 'text/xml')
43 # walk(dom.firstChild, wrapInTag(ALIEN_REGEX, 'alien'))
47 # window.ALIEN_REGEX = /[^a-zA-Z0-9ąćęłńóśźżĄĆĘŁŃÓŚŹŻ\s<>«»\\*_!,:;?&%."'=#()\/-]+/g
48 # " just for syntax coloring.