Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why manipulate strings at all?

Text are DOM nodes. If I were making a business of this I would automate the shit out of it by:

1) Gather all text nodes directly

2) Eliminate all text nodes that only contain white space

3) Add context. Since text nodes are DOM nodes you can get information about the containing element directly from the node itself.

Hands down walking the DOM will be programmatically faster to write and execute than anything else you can write in any language.

Here is some tiny code that does just that: https://github.com/prettydiff/semanticText



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: